




import os
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
					from .tokenization_big_bird import BigBirdTokenizer
else:
					UpperCamelCase__    			=			None

UpperCamelCase__    			=			logging.get_logger(__name__)
UpperCamelCase__    			=			{"""vocab_file""": """spiece.model""", """tokenizer_file""": """tokenizer.json"""}

UpperCamelCase__    			=			{
    """vocab_file""": {
        """google/bigbird-roberta-base""": """https://huggingface.co/google/bigbird-roberta-base/resolve/main/spiece.model""",
        """google/bigbird-roberta-large""": (
            """https://huggingface.co/google/bigbird-roberta-large/resolve/main/spiece.model"""
        ),
        """google/bigbird-base-trivia-itc""": (
            """https://huggingface.co/google/bigbird-base-trivia-itc/resolve/main/spiece.model"""
        ),
    },
    """tokenizer_file""": {
        """google/bigbird-roberta-base""": (
            """https://huggingface.co/google/bigbird-roberta-base/resolve/main/tokenizer.json"""
        ),
        """google/bigbird-roberta-large""": (
            """https://huggingface.co/google/bigbird-roberta-large/resolve/main/tokenizer.json"""
        ),
        """google/bigbird-base-trivia-itc""": (
            """https://huggingface.co/google/bigbird-base-trivia-itc/resolve/main/tokenizer.json"""
        ),
    },
}

UpperCamelCase__    			=			{
    """google/bigbird-roberta-base""": 4096,
    """google/bigbird-roberta-large""": 4096,
    """google/bigbird-base-trivia-itc""": 4096,
}


UpperCamelCase__    			=			"""▁"""
class 			a__    (					UpperCamelCase__      ):
						_a							:    Union[str, Any]					=    VOCAB_FILES_NAMES
						_a							:    Any					=    PRETRAINED_VOCAB_FILES_MAP
						_a							:    Dict					=    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						_a							:    Tuple					=    BigBirdTokenizer
						_a							:    Any					=    ["""input_ids""", """attention_mask"""]
						_a							:    List[int]					=    []






						def __init__(   self		,			_A=None		,			_A=None		,			_A="<unk>"		,			_A="<s>"		,			_A="</s>"		,			_A="<pad>"		,			_A="[SEP]"		,			_A="[MASK]"		,			_A="[CLS]"		,			**_A		,			):




											"""simple docstring"""



											__lowerCAmelCase				   =       AddedToken(lowerCAmelCase__		,			lstrip=lowerCAmelCase__		,			rstrip=lowerCAmelCase__			) if isinstance(lowerCAmelCase__		,			lowerCAmelCase__			) else bos_token
											__lowerCAmelCase				   =       AddedToken(lowerCAmelCase__		,			lstrip=lowerCAmelCase__		,			rstrip=lowerCAmelCase__			) if isinstance(lowerCAmelCase__		,			lowerCAmelCase__			) else eos_token
											__lowerCAmelCase				   =       AddedToken(lowerCAmelCase__		,			lstrip=lowerCAmelCase__		,			rstrip=lowerCAmelCase__			) if isinstance(lowerCAmelCase__		,			lowerCAmelCase__			) else unk_token
											__lowerCAmelCase				   =       AddedToken(lowerCAmelCase__		,			lstrip=lowerCAmelCase__		,			rstrip=lowerCAmelCase__			) if isinstance(lowerCAmelCase__		,			lowerCAmelCase__			) else pad_token
											__lowerCAmelCase				   =       AddedToken(lowerCAmelCase__		,			lstrip=lowerCAmelCase__		,			rstrip=lowerCAmelCase__			) if isinstance(lowerCAmelCase__		,			lowerCAmelCase__			) else cls_token
											__lowerCAmelCase				   =       AddedToken(lowerCAmelCase__		,			lstrip=lowerCAmelCase__		,			rstrip=lowerCAmelCase__			) if isinstance(lowerCAmelCase__		,			lowerCAmelCase__			) else sep_token

											# Mask token behave like a normal word, i.e. include the space before it
											__lowerCAmelCase				   =       AddedToken(lowerCAmelCase__		,			lstrip=lowerCAmelCase__		,			rstrip=lowerCAmelCase__			) if isinstance(lowerCAmelCase__		,			lowerCAmelCase__			) else mask_token

											super().__init__(
											    lowerCAmelCase__		,			tokenizer_file=lowerCAmelCase__		,			bos_token=lowerCAmelCase__		,			eos_token=lowerCAmelCase__		,			unk_token=lowerCAmelCase__		,			sep_token=lowerCAmelCase__		,			pad_token=lowerCAmelCase__		,			cls_token=lowerCAmelCase__		,			mask_token=lowerCAmelCase__		,			**lowerCAmelCase__		,			)

											__lowerCAmelCase				   =       vocab_file
											__lowerCAmelCase				   =       False if not self.vocab_file else True






						def 				__SCREAMING_SNAKE_CASE(   self		,			_A		,			_A = None			):




											"""simple docstring"""



											__lowerCAmelCase				   =       [self.sep_token_id]
											__lowerCAmelCase				   =       [self.cls_token_id]
											if token_ids_a is None:
																return cls + token_ids_a + sep
											return cls + token_ids_a + sep + token_ids_a + sep






						def 				__SCREAMING_SNAKE_CASE(   self		,			_A		,			_A = None		,			_A = False			):




											"""simple docstring"""



											if already_has_special_tokens:
																if token_ids_a is not None:
																					raise ValueError(
																					    "You should not supply a second sequence if the provided sequence of "
																					    "ids is already formatted with special tokens for the model."			)
																return [1 if x in [self.sep_token_id, self.cls_token_id] else 0 for x in token_ids_a]

											if token_ids_a is None:
																return [1] + ([0] * len(lowerCAmelCase__			)) + [1]
											return [1] + ([0] * len(lowerCAmelCase__			)) + [1] + ([0] * len(lowerCAmelCase__			)) + [1]






						def 				__SCREAMING_SNAKE_CASE(   self		,			_A		,			_A = None			):




											"""simple docstring"""



											__lowerCAmelCase				   =       [self.sep_token_id]
											__lowerCAmelCase				   =       [self.cls_token_id]

											if token_ids_a is None:
																return len(cls + token_ids_a + sep			) * [0]
											return len(cls + token_ids_a + sep			) * [0] + len(token_ids_a + sep			) * [1]






						def 				__SCREAMING_SNAKE_CASE(   self		,			_A		,			_A = None			):




											"""simple docstring"""



											if not self.can_save_slow_tokenizer:
																raise ValueError(
																    "Your fast tokenizer does not have the necessary information to save the vocabulary for a slow "
																    "tokenizer."			)

											if not os.path.isdir(lowerCAmelCase__			):
																logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""			)
																return
											__lowerCAmelCase				   =       os.path.join(
											    lowerCAmelCase__		,			(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]			)

											if os.path.abspath(self.vocab_file			) != os.path.abspath(lowerCAmelCase__			):
																copyfile(self.vocab_file		,			lowerCAmelCase__			)

											return (out_vocab_file,)











from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCAmelCase	:	Dict		     =       logging.get_logger(__name__)

UpperCAmelCase	:	Tuple		     =       {
    """caidas/swin2sr-classicalsr-x2-64""": (
        """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json"""
    ),
}







class 				__lowerCAmelCase       (    UpperCamelCase__):
      _lowercase				:					Any						=			"""swin2sr"""

      _lowercase				:					Tuple						=			{
          """hidden_size""": """embed_dim""",
          """num_attention_heads""": """num_heads""",
          """num_hidden_layers""": """num_layers""",
      }







      def __init__(    self		,      lowerCAmelCase__=6_4		,      lowerCAmelCase__=1		,      lowerCAmelCase__=3		,      lowerCAmelCase__=1_8_0		,      lowerCAmelCase__=[6, 6, 6, 6, 6, 6]		,      lowerCAmelCase__=[6, 6, 6, 6, 6, 6]		,      lowerCAmelCase__=8		,      lowerCAmelCase__=2.0		,      lowerCAmelCase__=True		,      lowerCAmelCase__=0.0		,      lowerCAmelCase__=0.0		,      lowerCAmelCase__=0.1		,      lowerCAmelCase__="gelu"		,      lowerCAmelCase__=False		,      lowerCAmelCase__=0.02		,      lowerCAmelCase__=1E-5		,      lowerCAmelCase__=2		,      lowerCAmelCase__=1.0		,      lowerCAmelCase__="1conv"		,      lowerCAmelCase__="pixelshuffle"		,      **lowerCAmelCase__		,      )   ->						int:



        '''simple docstring'''




        super().__init__(**lowerCAmelCase__							)

        a__	:					Optional[Any]										=image_size
        a__	:					Dict										=patch_size
        a__	:					Tuple										=num_channels
        a__	:					Union[str, Any]										=embed_dim
        a__	:					Optional[Any]										=depths
        a__	:					List[str]										=len(lowerCAmelCase__							)
        a__	:					Any										=num_heads
        a__	:					Any										=window_size
        a__	:					str										=mlp_ratio
        a__	:					List[str]										=qkv_bias
        a__	:					Dict										=hidden_dropout_prob
        a__	:					List[str]										=attention_probs_dropout_prob
        a__	:					Dict										=drop_path_rate
        a__	:					Optional[Any]										=hidden_act
        a__	:					Union[str, Any]										=use_absolute_embeddings
        a__	:					Optional[Any]										=layer_norm_eps
        a__	:					List[Any]										=initializer_range
        a__	:					int										=upscale
        a__	:					Optional[int]										=img_range
        a__	:					Any										=resi_connection
        a__	:					Optional[Any]										=upsampler






