





'''simple docstring'''






from typing import Dict, List, Optional, Tuple

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


__UpperCamelCase										=  logging.get_logger(__name__)




class    _A   (				__lowercase		):
		lowercase__:      str							    =      ['''input_ids''', '''attention_mask''']

		def __init__(      self				:      Tuple     ,			__magic_name__				:      Any="[PAD]"     ,			__magic_name__				:      List[Any]="[BOS]"     ,			__magic_name__				:      List[Any]="[EOS]"     ,			__magic_name__				:      List[str]="[MASK]"     ,			__magic_name__				:      List[str]="[CLS]"     ,			__magic_name__				:      Optional[int]="[SEP]"     ,			__magic_name__				:      Optional[Any]=20_48     ,			**__magic_name__				:      List[str]     ,			)				->						None:


					"""simple docstring"""

					__snake_case				:			Optional[int]       			=    AddedToken(__magic_name__     ,			lstrip=__magic_name__     ,			rstrip=__magic_name__ ) if isinstance(__magic_name__     ,			__magic_name__ ) else pad_token
					__snake_case				:			Tuple       			=    AddedToken(__magic_name__     ,			lstrip=__magic_name__     ,			rstrip=__magic_name__ ) if isinstance(__magic_name__     ,			__magic_name__ ) else bos_token
					__snake_case				:			Optional[Any]       			=    AddedToken(__magic_name__     ,			lstrip=__magic_name__     ,			rstrip=__magic_name__ ) if isinstance(__magic_name__     ,			__magic_name__ ) else eos_token
					__snake_case				:			Union[str, Any]       			=    AddedToken(__magic_name__     ,			lstrip=__magic_name__     ,			rstrip=__magic_name__ ) if isinstance(__magic_name__     ,			__magic_name__ ) else mask_token
					__snake_case				:			Optional[int]       			=    AddedToken(__magic_name__     ,			lstrip=__magic_name__     ,			rstrip=__magic_name__ ) if isinstance(__magic_name__     ,			__magic_name__ ) else cls_token
					__snake_case				:			List[Any]       			=    AddedToken(__magic_name__     ,			lstrip=__magic_name__     ,			rstrip=__magic_name__ ) if isinstance(__magic_name__     ,			__magic_name__ ) else sep_token

					super().__init__(
					    pad_token=__magic_name__     ,			bos_token=__magic_name__     ,			eos_token=__magic_name__     ,			mask_token=__magic_name__     ,			cls_token=__magic_name__     ,			sep_token=__magic_name__     ,			model_max_length=__magic_name__     ,			**__magic_name__     ,			)

					__snake_case				:			str       			=    2**8  # utf is 8 bits

					# define special tokens dict
					__snake_case				:			Dict[str, int]       			=    {
					    self.pad_token: 0,
					    self.bos_token: 1,
					    self.eos_token: 2,
					    self.mask_token: 3,
					    self.cls_token: 4,
					    self.sep_token: 5,
					}
					__snake_case				:			int       			=    len(self.special_tokens_encoder )
					__snake_case				:			Dict[int, str]       			=    {v: k for k, v in self.special_tokens_encoder.items()}

		def   lowercase__    (      self				:      List[str] )				->						Dict[str, int]:


					"""simple docstring"""

					__snake_case				:			Optional[int]       			=    self.special_tokens_encoder.copy()
					vocab.update(self.added_tokens_encoder )
					for i in range(self._utf_vocab_size ):
								__snake_case				:			str       			=    chr(__magic_name__ )
								__snake_case				:			Tuple       			=    i + len(self.special_tokens_encoder )
					return vocab

		@property
		def   lowercase__    (      self				:      str )				->						int:


					"""simple docstring"""

					return self._utf_vocab_size + self._num_special_tokens

		def   lowercase__    (      self				:      Union[str, Any]     ,			__magic_name__				:      List[int]     ,			__magic_name__				:      Optional[List[int]] = None     ,			__magic_name__				:      bool = False )				->						List[int]:


					"""simple docstring"""

					if already_has_special_tokens:
								return super().get_special_tokens_mask(
								    token_ids_a=__magic_name__     ,			token_ids_a=__magic_name__     ,			already_has_special_tokens=__magic_name__ )

					# normal case: some special tokens
					if token_ids_a is None:
								return [1] + [0] * len(__magic_name__ ) + [1]
					return [1] + ([0] * len(__magic_name__ )) + [1] + ([0] * len(__magic_name__ )) + [1]

		def   lowercase__    (      self				:      Optional[int]     ,			__magic_name__				:      List[int]     ,			__magic_name__				:      Optional[List[int]] = None )				->						List[int]:


					"""simple docstring"""

					if token_ids_a is None:
								return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
					else:
								return [self.cls_token_id] + token_ids_a + [self.sep_token_id] + token_ids_a + [self.sep_token_id]

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


					"""simple docstring"""

					__snake_case				:			List[str]       			=    [chr(__magic_name__ ) for i in text.encode("""utf-8""" )]
					return tokens

		def   lowercase__    (      self				:      int     ,			__magic_name__				:      List[Any] )				->						Optional[Any]:


					"""simple docstring"""

					if token in self.special_tokens_encoder:
								__snake_case				:			Tuple       			=    self.special_tokens_encoder[token]
					elif token in self.added_tokens_encoder:
								__snake_case				:			Dict       			=    self.added_tokens_encoder[token]
					elif len(__magic_name__ ) != 1:
								__snake_case				:			Dict       			=    self.unk_token_id
					else:
								__snake_case				:			Any       			=    ord(__magic_name__ ) + self._num_special_tokens
					return token_id

		def   lowercase__    (      self				:      Tuple     ,			__magic_name__				:      List[str] )				->						Optional[int]:


					"""simple docstring"""

					if index in self.special_tokens_decoder:
								__snake_case				:			Optional[int]       			=    self.special_tokens_decoder[index]
					elif index in self.added_tokens_decoder:
								__snake_case				:			Union[str, Any]       			=    self.added_tokens_decoder[index]
					else:
								__snake_case				:			Tuple       			=    chr(index - self._num_special_tokens )
					return token

		def   lowercase__    (      self				:      Dict     ,			__magic_name__				:      int )				->						Optional[int]:


					"""simple docstring"""

					__snake_case				:			Any       			=    B""""""
					for token in tokens:
								if token in self.special_tokens_decoder:
											__snake_case				:			List[str]       			=    self.special_tokens_decoder[token].encode("""utf-8""" )
								elif token in self.added_tokens_decoder:
											__snake_case				:			Tuple       			=    self.special_tokens_decoder[token].encode("""utf-8""" )
								elif token in self.special_tokens_encoder:
											__snake_case				:			List[str]       			=    token.encode("""utf-8""" )
								elif token in self.added_tokens_encoder:
											__snake_case				:			Dict       			=    token.encode("""utf-8""" )
								else:
											__snake_case				:			List[Any]       			=    bytes([ord(__magic_name__ )] )
								bstring += tok_string
					__snake_case				:			int       			=    bstring.decode("""utf-8"""     ,			errors="""replace""" )
					return string

		def   lowercase__    (      self				:      List[Any]     ,			__magic_name__				:      str     ,			__magic_name__				:      Optional[str] = None )				->						Tuple[str]:


					"""simple docstring"""

					return ()










'''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__)


