


from typing import Dict, List, Optional

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


__magic_name__  	=     logging.get_logger(__name__)


__magic_name__  	=     {
    '''nielsr/canine-s''': 2_0_4_8,
}

# Unicode defines 1,114,112 total “codepoints”
__magic_name__  	=     1_1_1_4_1_1_2

# Below: Constants defining canonical codepoints for special, pseudo-characters.
# Copied from https://github.com/google-research/language/blob/master/language/canine/special_codepoints.py
__magic_name__  	=     0

__magic_name__  	=     0XE_000
__magic_name__  	=     0XE_001
__magic_name__  	=     0XE_002
__magic_name__  	=     0XE_003
__magic_name__  	=     0XE_004

# Maps special codepoints to human-readable names.
__magic_name__  	=     {
    # Special symbols are represented using codepoints values that are valid,
    # but designated as "Private Use", meaning that they will never be assigned
    # characters by the Unicode Consortium, and are thus safe for use here.
    #
    # NOTE: Do *NOT* add any sort of [UNK_CHAR] here. They are explicitly
    # excluded and should fail with a hard error.
    CLS: '''[CLS]''',
    SEP: '''[SEP]''',
    BOS: '''[BOS]''',
    MASK: '''[MASK]''',
    PAD: '''[PAD]''',
    RESERVED: '''[RESERVED]''',
}

# Maps special codepoint human-readable names to their codepoint values.
__magic_name__  	=     {name: codepoint for codepoint, name in SPECIAL_CODEPOINTS.items()}





class        lowerCAmelCase__ (					__lowerCamelCase  ):






						"""simple docstring"""
						__UpperCAmelCase       :						Optional[Any]    	=			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES




						def __init__(       self ,				a_=chr(a_      ) ,				a_=chr(a_      ) ,				a_=chr(a_      ) ,				a_=chr(a_      ) ,				a_=chr(a_      ) ,				a_=chr(a_      ) ,				a_=False ,				a_=2048 ,				**a_ ,				):
							lowerCamelCase_					:				int              =  AddedToken(a_ ,				lstrip=a_ ,				rstrip=a_      ) if isinstance(a_ ,				a_      ) else bos_token
							lowerCamelCase_					:				int              =  AddedToken(a_ ,				lstrip=a_ ,				rstrip=a_      ) if isinstance(a_ ,				a_      ) else eos_token
							lowerCamelCase_					:				str              =  AddedToken(a_ ,				lstrip=a_ ,				rstrip=a_      ) if isinstance(a_ ,				a_      ) else sep_token
							lowerCamelCase_					:				str              =  AddedToken(a_ ,				lstrip=a_ ,				rstrip=a_      ) if isinstance(a_ ,				a_      ) else cls_token
							lowerCamelCase_					:				str              =  AddedToken(a_ ,				lstrip=a_ ,				rstrip=a_      ) if isinstance(a_ ,				a_      ) else pad_token

							# Mask token behave like a normal word, i.e. include the space before it
							lowerCamelCase_					:				List[Any]              =  AddedToken(a_ ,				lstrip=a_ ,				rstrip=a_      ) if isinstance(a_ ,				a_      ) else mask_token

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

							# Creates a mapping for looking up the IDs of special symbols.
							lowerCamelCase_					:				Optional[int]              =  {}
							for codepoint, name in SPECIAL_CODEPOINTS.items():
								lowerCamelCase_					:				Tuple              =  codepoint

							# Creates a mapping for looking up the string forms of special symbol IDs.
							lowerCamelCase_					:				List[Any]              =  {
							    codepoint: name for name, codepoint in self._special_codepoints.items()
							}

							lowerCamelCase_					:				str              =  UNICODE_VOCAB_SIZE
							lowerCamelCase_					:				Any              =  len(self._special_codepoints      )




						@property
						def 	_UpperCamelCase					(       self      ):
							return self._unicode_vocab_size




						def 	_UpperCamelCase					(       self ,				a_      ):
							return list(a_      )




						def 	_UpperCamelCase					(       self ,				a_      ):
							try:
								return ord(a_      )
							except TypeError:
								raise ValueError(F"""invalid token: '{token}'"""      )




						def 	_UpperCamelCase					(       self ,				a_      ):
							try:
								if index in SPECIAL_CODEPOINTS:
									return SPECIAL_CODEPOINTS[index]
								return chr(a_      )
							except TypeError:
								raise ValueError(F"""invalid id: {index}"""      )




						def 	_UpperCamelCase					(       self ,				a_      ):
							return "".join(a_      )




						def 	_UpperCamelCase					(       self ,				a_ ,				a_ = None      ):
							lowerCamelCase_					:				List[str]              =  [self.sep_token_id]
							lowerCamelCase_					:				Dict              =  [self.cls_token_id]

							lowerCamelCase_					:				Optional[Any]              =  cls + token_ids_a + sep
							if token_ids_a is not None:
								result += token_ids_a + sep
							return result




						def 	_UpperCamelCase					(       self ,				a_ ,				a_ = None ,				a_ = False      ):
							if already_has_special_tokens:
								return super().get_special_tokens_mask(
								    token_ids_a=a_ ,				token_ids_a=a_ ,				already_has_special_tokens=a_      )

							lowerCamelCase_					:				List[Any]              =  [1] + ([0] * len(a_      )) + [1]
							if token_ids_a is not None:
								result += ([0] * len(a_      )) + [1]
							return result




						def 	_UpperCamelCase					(       self ,				a_ ,				a_ = None      ):
							lowerCamelCase_					:				str              =  [self.sep_token_id]
							lowerCamelCase_					:				int              =  [self.cls_token_id]

							lowerCamelCase_					:				Optional[int]              =  len(cls + token_ids_a + sep      ) * [0]
							if token_ids_a is not None:
								result += len(token_ids_a + sep      ) * [1]
							return result




						def 	_UpperCamelCase					(       self ,				a_ ,				a_ = None      ):
							return ()







'''simple docstring'''


import warnings
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCAmelCase_					=   logging.get_logger(__name__)

UpperCAmelCase_					=   {
    "nvidia/segformer-b0-finetuned-ade-512-512": (
        "https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512/resolve/main/config.json"
    ),
    # See all SegFormer models at https://huggingface.co/models?filter=segformer
}





class  __lowercase    (	__magic_name__			):
   _a    						=   """segformer"""







   def __init__(						self   ,				UpperCamelCase=3   ,				UpperCamelCase=4   ,				UpperCamelCase=[2, 2, 2, 2]   ,				UpperCamelCase=[8, 4, 2, 1]   ,				UpperCamelCase=[32, 64, 160, 256]   ,				UpperCamelCase=[7, 3, 3, 3]   ,				UpperCamelCase=[4, 2, 2, 2]   ,				UpperCamelCase=[1, 2, 5, 8]   ,				UpperCamelCase=[4, 4, 4, 4]   ,				UpperCamelCase="gelu"   ,				UpperCamelCase=0.0   ,				UpperCamelCase=0.0   ,				UpperCamelCase=0.1   ,				UpperCamelCase=0.02   ,				UpperCamelCase=0.1   ,				UpperCamelCase=1e-6   ,				UpperCamelCase=256   ,				UpperCamelCase=255   ,				**UpperCamelCase   ,				)					->     int:
     super().__init__(**UpperCamelCase   )

     if "reshape_last_stage" in kwargs and kwargs["reshape_last_stage"] is False:
       warnings.warn(
           'Reshape_last_stage is set to False in this config. This argument is deprecated and will soon be'
           ' removed, as the behaviour will default to that of reshape_last_stage = True.'   ,				UpperCamelCase   ,				)

     __a								=       num_channels
     __a								=       num_encoder_blocks
     __a								=       depths
     __a								=       sr_ratios
     __a								=       hidden_sizes
     __a								=       patch_sizes
     __a								=       strides
     __a								=       mlp_ratios
     __a								=       num_attention_heads
     __a								=       hidden_act
     __a								=       hidden_dropout_prob
     __a								=       attention_probs_dropout_prob
     __a								=       classifier_dropout_prob
     __a								=       initializer_range
     __a								=       drop_path_rate
     __a								=       layer_norm_eps
     __a								=       decoder_hidden_size
     __a								=       kwargs.get('reshape_last_stage'   ,				UpperCamelCase   )
     __a								=       semantic_loss_ignore_index





class  __lowercase    (	__magic_name__			):
   _a    						=   version.parse("""1.11"""			)







   @property
   def 		UpperCamelCase__      (						self   )					->     Mapping[str, Mapping[int, str]]:
     return OrderedDict(
         [
             ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
         ]   )







   @property
   def 		UpperCamelCase__      (						self   )					->     float:
     return 1e-4







   @property
   def 		UpperCamelCase__      (						self   )					->     int:
     return 12



