



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


__a          =		logging.get_logger(__name__)

__a          =		{
    "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     UpperCAmelCase_       (       _a	):
    """simple docstring"""







    lowercase					=		"segformer"




    def __init__(    self					:     List[str] ,     snake_case_					:     Dict=3 ,     snake_case_					:     str=4 ,     snake_case_					:     List[str]=[2, 2, 2, 2] ,     snake_case_					:     Dict=[8, 4, 2, 1] ,     snake_case_					:     Dict=[32, 64, 160, 256] ,     snake_case_					:     Union[str, Any]=[7, 3, 3, 3] ,     snake_case_					:     Dict=[4, 2, 2, 2] ,     snake_case_					:     Any=[1, 2, 5, 8] ,     snake_case_					:     Union[str, Any]=[4, 4, 4, 4] ,     snake_case_					:     Dict="gelu" ,     snake_case_					:     Any=0.0 ,     snake_case_					:     List[str]=0.0 ,     snake_case_					:     List[str]=0.1 ,     snake_case_					:     Dict=0.02 ,     snake_case_					:     int=0.1 ,     snake_case_					:     str=1E-6 ,     snake_case_					:     Optional[int]=256 ,     snake_case_					:     int=255 ,     **snake_case_					:     List[str] ,     ):
          super().__init__(**snake_case_						)

          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.""" ,     snake_case_ ,     )

          snake_case__  :    List[str]    						=      num_channels
          snake_case__  :    List[str]    						=      num_encoder_blocks
          snake_case__  :    str    						=      depths
          snake_case__  :    Optional[Any]    						=      sr_ratios
          snake_case__  :    Optional[Any]    						=      hidden_sizes
          snake_case__  :    Any    						=      patch_sizes
          snake_case__  :    Optional[Any]    						=      strides
          snake_case__  :    Dict    						=      mlp_ratios
          snake_case__  :    Any    						=      num_attention_heads
          snake_case__  :    int    						=      hidden_act
          snake_case__  :    List[str]    						=      hidden_dropout_prob
          snake_case__  :    List[Any]    						=      attention_probs_dropout_prob
          snake_case__  :    List[Any]    						=      classifier_dropout_prob
          snake_case__  :    Union[str, Any]    						=      initializer_range
          snake_case__  :    Tuple    						=      drop_path_rate
          snake_case__  :    List[Any]    						=      layer_norm_eps
          snake_case__  :    Dict    						=      decoder_hidden_size
          snake_case__  :    Tuple    						=      kwargs.get("""reshape_last_stage""" ,     snake_case_						)
          snake_case__  :    Dict    						=      semantic_loss_ignore_index







class     UpperCAmelCase_       (       _a	):
    """simple docstring"""







    lowercase					=		version.parse("1.11"	)




    @property
    def lowerCamelCase       (    self					:     Union[str, Any]						):
          return OrderedDict(
              [
                  ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
              ]						)




    @property
    def lowerCamelCase       (    self					:     Any						):
          return 1E-4




    @property
    def lowerCamelCase       (    self					:     int						):
          return 12





'''simple docstring'''





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers
from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_roformer import RoFormerTokenizer
from .tokenization_utils import JiebaPreTokenizer


__a          =		logging.get_logger(__name__)

__a          =		{"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

__a          =		{
    "vocab_file": {
        "junnyu/roformer_chinese_small": "https://huggingface.co/junnyu/roformer_chinese_small/resolve/main/vocab.txt",
        "junnyu/roformer_chinese_base": "https://huggingface.co/junnyu/roformer_chinese_base/resolve/main/vocab.txt",
        "junnyu/roformer_chinese_char_small": (
            "https://huggingface.co/junnyu/roformer_chinese_char_small/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_chinese_char_base": (
            "https://huggingface.co/junnyu/roformer_chinese_char_base/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_small_discriminator": (
            "https://huggingface.co/junnyu/roformer_small_discriminator/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_small_generator": (
            "https://huggingface.co/junnyu/roformer_small_generator/resolve/main/vocab.txt"
        ),
    }
}

__a          =		{
    "junnyu/roformer_chinese_small": 1536,
    "junnyu/roformer_chinese_base": 1536,
    "junnyu/roformer_chinese_char_small": 512,
    "junnyu/roformer_chinese_char_base": 512,
    "junnyu/roformer_small_discriminator": 128,
    "junnyu/roformer_small_generator": 128,
}


__a          =		{
    "junnyu/roformer_chinese_small": {"do_lower_case": True},
    "junnyu/roformer_chinese_base": {"do_lower_case": True},
    "junnyu/roformer_chinese_char_small": {"do_lower_case": True},
    "junnyu/roformer_chinese_char_base": {"do_lower_case": True},
    "junnyu/roformer_small_discriminator": {"do_lower_case": True},
    "junnyu/roformer_small_generator": {"do_lower_case": True},
}







class     UpperCAmelCase_       (       _a	):
    """simple docstring"""







    lowercase					=		VOCAB_FILES_NAMES
    lowercase					=		PRETRAINED_VOCAB_FILES_MAP
    lowercase					=		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    lowercase					=		PRETRAINED_INIT_CONFIGURATION
    lowercase					=		RoFormerTokenizer




    def __init__(    self					:     List[Any] ,     snake_case_					:     List[str]=None ,     snake_case_					:     Dict=None ,     snake_case_					:     Any=True ,     snake_case_					:     str="[UNK]" ,     snake_case_					:     List[str]="[SEP]" ,     snake_case_					:     Optional[Any]="[PAD]" ,     snake_case_					:     Union[str, Any]="[CLS]" ,     snake_case_					:     Union[str, Any]="[MASK]" ,     snake_case_					:     List[Any]=True ,     snake_case_					:     Optional[Any]=None ,     **snake_case_					:     Tuple ,     ):
          super().__init__(
              snake_case_ ,     tokenizer_file=snake_case_ ,     do_lower_case=snake_case_ ,     unk_token=snake_case_ ,     sep_token=snake_case_ ,     pad_token=snake_case_ ,     cls_token=snake_case_ ,     mask_token=snake_case_ ,     tokenize_chinese_chars=snake_case_ ,     strip_accents=snake_case_ ,     **snake_case_ ,     )

          snake_case__  :    str    						=      json.loads(self.backend_tokenizer.normalizer.__getstate__()						)
          if (
              pre_tok_state.get("""lowercase""" ,     snake_case_						) != do_lower_case
              or pre_tok_state.get("""strip_accents""" ,     snake_case_						) != strip_accents
          ):
                snake_case__  :    str    						=      getattr(snake_case_ ,     pre_tok_state.pop("""type"""						)						)
                snake_case__  :    Optional[int]    						=      do_lower_case
                snake_case__  :    Union[str, Any]    						=      strip_accents
                snake_case__  :    Union[str, Any]    						=      pre_tok_class(**snake_case_						)

          snake_case__  :    str    						=      do_lower_case




    def __getstate__(    self					:     int						):
          snake_case__  :    List[Any]    						=      self.__dict__.copy()
          snake_case__  :    str    						=      BertPreTokenizer()
          return state




    def __setstate__(    self					:     Dict ,     snake_case_					:     Dict						):
          snake_case__  :    List[Any]    						=      d
          snake_case__  :    Union[str, Any]    						=      self.__dict__["""_tokenizer"""].get_vocab()
          snake_case__  :    List[Any]    						=      PreTokenizer.custom(JiebaPreTokenizer(snake_case_						)						)




    def lowerCamelCase       (    self					:     str ,     snake_case_					:     Optional[Any] ,     snake_case_					:     List[str]=None						):
          snake_case__  :    str    						=      [self.cls_token_id] + token_ids_a + [self.sep_token_id]

          if token_ids_a:
                output += token_ids_a + [self.sep_token_id]

          return output




    def lowerCamelCase       (    self					:     str ,     snake_case_					:     List[int] ,     snake_case_					:     Optional[List[int]] = None						):
          snake_case__  :    int    						=      [self.sep_token_id]
          snake_case__  :    str    						=      [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 lowerCamelCase       (    self					:     Dict ,     snake_case_					:     str ,     snake_case_					:     Optional[str] = None						):
          snake_case__  :    Union[str, Any]    						=      self._tokenizer.model.save(snake_case_ ,     name=snake_case_						)
          return tuple(snake_case_						)




    def lowerCamelCase       (    self					:     Dict ,     snake_case_					:     List[str] ,     snake_case_					:     Tuple=None ,     snake_case_					:     List[str]=None ,     snake_case_					:     Union[str, Any]=False ,     **snake_case_					:     Tuple ,     ):
          snake_case__  :    Optional[Any]    						=      BertPreTokenizer()
          return super().save_pretrained(snake_case_ ,     snake_case_ ,     snake_case_ ,     snake_case_ ,     **snake_case_						)
