





'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


__UpperCamelCase										=  {
    "configuration_swin2sr": ["SWIN2SR_PRETRAINED_CONFIG_ARCHIVE_MAP", "Swin2SRConfig"],
}


try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__UpperCamelCase										=  [
	    "SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST",
	    "Swin2SRForImageSuperResolution",
	    "Swin2SRModel",
	    "Swin2SRPreTrainedModel",
	]


try:
	if not is_vision_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__UpperCamelCase										=  ["Swin2SRImageProcessor"]


if TYPE_CHECKING:
	from .configuration_swinasr import SWIN2SR_PRETRAINED_CONFIG_ARCHIVE_MAP, SwinaSRConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_swinasr import (
		    SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST,
		    SwinaSRForImageSuperResolution,
		    SwinaSRModel,
		    SwinaSRPreTrainedModel,
		)

	try:
		if not is_vision_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .image_processing_swinasr import SwinaSRImageProcessor


else:
	import sys

	__UpperCamelCase										=  _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)









'''simple docstring'''






import os
import tempfile
import unittest
from typing import List

from transformers.models.esm.tokenization_esm import VOCAB_FILES_NAMES, EsmTokenizer
from transformers.testing_utils import require_tokenizers
from transformers.tokenization_utils import PreTrainedTokenizer
from transformers.tokenization_utils_base import PreTrainedTokenizerBase




@require_tokenizers
class    _A   (				unittest.TestCase		):
		lowercase__:      Tuple							    =      EsmTokenizer

		def   lowercase__    (      self				:      Tuple )				->						Optional[int]:


					"""simple docstring"""

					super().setUp()
					__snake_case				:			str       			=    tempfile.mkdtemp()
					# fmt: off
					__snake_case				:			List[str]       			=    ["<cls>", "<pad>", "<eos>", "<unk>", "L", "A", "G", "V", "S", "E", "R", "T", "I", "D", "P", "K", "Q", "N", "F", "Y", "M", "H", "W", "C", "X", "B", "U", "Z", "O", ".", "-", "<null_1>", "<mask>"]  # noqa: E501
					# fmt: on
					__snake_case				:			Tuple       			=    os.path.join(self.tmpdirname     ,			VOCAB_FILES_NAMES["""vocab_file"""] )
					with open(self.vocab_file     ,			"""w"""     ,			encoding="""utf-8""" ) as vocab_writer:
								vocab_writer.write("""""".join([x + """\n""" for x in vocab_tokens] ) )

		def   lowercase__    (      self				:      List[Any]     ,			**__magic_name__				:      Tuple )				->						List[PreTrainedTokenizerBase]:


					"""simple docstring"""

					return [self.get_tokenizer(**__magic_name__ )]

		def   lowercase__    (      self				:      int     ,			**__magic_name__				:      Dict )				->						PreTrainedTokenizer:


					"""simple docstring"""

					return self.tokenizer_class.from_pretrained(self.tmpdirname     ,			**__magic_name__ )

		def   lowercase__    (      self				:      Union[str, Any] )				->						Dict:


					"""simple docstring"""

					__snake_case				:			Dict       			=    self.tokenizer_class(self.vocab_file )

					__snake_case				:			Optional[int]       			=    tokenizer.tokenize("""LAGVS""" )
					self.assertListEqual(__magic_name__     ,			["""L""", """A""", """G""", """V""", """S"""] )
					self.assertListEqual(tokenizer.convert_tokens_to_ids(__magic_name__ )     ,			[4, 5, 6, 7, 8] )

		def   lowercase__    (      self				:      List[str] )				->						Optional[Any]:


					"""simple docstring"""

					__snake_case				:			str       			=    self.tokenizer_class(self.vocab_file )

					__snake_case				:			Optional[int]       			=    """LAGVS"""
					self.assertListEqual(tokenizer.encode(__magic_name__ )     ,			[0, 4, 5, 6, 7, 8, 2] )

		def   lowercase__    (      self				:      str )				->						Optional[Any]:


					"""simple docstring"""

					__snake_case				:			Dict       			=    self.tokenizer_class(self.vocab_file )

					__snake_case				:			Tuple       			=    ["""LAGVS""", """WCB"""]
					__snake_case				:			Dict       			=    tokenizer(__magic_name__     ,			padding=__magic_name__ )["""input_ids"""]

					self.assertListEqual(__magic_name__     ,			[[0, 4, 5, 6, 7, 8, 2], [0, 22, 23, 25, 2]] )

		def   lowercase__    (      self				:      str )				->						List[Any]:


					"""simple docstring"""

					__snake_case				:			int       			=    self.tokenizer_class(self.vocab_file )

					__snake_case				:			List[Any]       			=    ["""LAGVS""", """WCB"""]
					__snake_case				:			Any       			=    tokenizer(__magic_name__     ,			padding=__magic_name__ )["""input_ids"""]

					self.assertListEqual(__magic_name__     ,			[[0, 4, 5, 6, 7, 8, 2], [0, 22, 23, 25, 2, 1, 1]] )

		def   lowercase__    (      self				:      List[str] )				->						Tuple:


					"""simple docstring"""

					__snake_case				:			Any       			=    self.get_tokenizers(fast=__magic_name__ )
					for tokenizer in tokenizers:
								with self.subTest(f'''{tokenizer.__class__.__name__}''' ):
											__snake_case				:			int       			=    """<unk>"""
											__snake_case				:			Optional[Any]       			=    """<mask>"""

											__snake_case				:			Tuple       			=    tokenizer.tokenize(__magic_name__ )
											__snake_case				:			List[Any]       			=    tokenizer.tokenize(__magic_name__ )

											self.assertEqual(len(__magic_name__ )     ,			1 )
											self.assertEqual(len(__magic_name__ )     ,			1 )
											self.assertEqual(token_a[0]     ,			__magic_name__ )
											self.assertEqual(token_a[0]     ,			__magic_name__ )


