




"""simple docstring"""



import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_convbert import ConvBertTokenizer


SCREAMING_SNAKE_CASE    =	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE    =	{"vocab_file": "vocab.txt"}

SCREAMING_SNAKE_CASE    =	{
    "vocab_file": {
        "YituTech/conv-bert-base": "https://huggingface.co/YituTech/conv-bert-base/resolve/main/vocab.txt",
        "YituTech/conv-bert-medium-small": (
            "https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/vocab.txt"
        ),
        "YituTech/conv-bert-small": "https://huggingface.co/YituTech/conv-bert-small/resolve/main/vocab.txt",
    }
}

SCREAMING_SNAKE_CASE    =	{
    "YituTech/conv-bert-base": 512,
    "YituTech/conv-bert-medium-small": 512,
    "YituTech/conv-bert-small": 512,
}


SCREAMING_SNAKE_CASE    =	{
    "YituTech/conv-bert-base": {"do_lower_case": True},
    "YituTech/conv-bert-medium-small": {"do_lower_case": True},
    "YituTech/conv-bert-small": {"do_lower_case": True},
}




class      UpperCAmelCase_  (						A_							):
    lowercase__						 =				VOCAB_FILES_NAMES
    lowercase__						 =				PRETRAINED_VOCAB_FILES_MAP
    lowercase__						 =				PRETRAINED_INIT_CONFIGURATION
    lowercase__						 =				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    lowercase__						 =				ConvBertTokenizer




    def __init__(   self						:	int     ,			snake_case_						:	Dict=None     ,			snake_case_						:	int=None     ,			snake_case_						:	int=True     ,			snake_case_						:	int="[UNK]"     ,			snake_case_						:	str="[SEP]"     ,			snake_case_						:	Tuple="[PAD]"     ,			snake_case_						:	Optional[Any]="[CLS]"     ,			snake_case_						:	List[Any]="[MASK]"     ,			snake_case_						:	Optional[Any]=True     ,			snake_case_						:	Dict=None     ,			**snake_case_						:	str     ,			)				->							List[Any]:




     '''simple docstring'''

     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_     ,			)

     A__	=    json.loads(self.backend_tokenizer.normalizer.__getstate__()				)
     if (
         normalizer_state.get("lowercase"     ,			snake_case_				) != do_lower_case
         or normalizer_state.get("strip_accents"     ,			snake_case_				) != strip_accents
         or normalizer_state.get("handle_chinese_chars"     ,			snake_case_				) != tokenize_chinese_chars
     ):
      A__	=    getattr(snake_case_     ,			normalizer_state.pop("type"				)				)
      A__	=    do_lower_case
      A__	=    strip_accents
      A__	=    tokenize_chinese_chars
      A__	=    normalizer_class(**snake_case_				)

     A__	=    do_lower_case




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




     '''simple docstring'''

     A__	=    [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 							__magic_name__							(   self						:	str     ,			snake_case_						:	List[int]     ,			snake_case_						:	Optional[List[int]] = None				)				->							List[int]:




     '''simple docstring'''

     A__	=    [self.sep_token_id]
     A__	=    [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 							__magic_name__							(   self						:	Any     ,			snake_case_						:	str     ,			snake_case_						:	Optional[str] = None				)				->							Tuple[str]:




     '''simple docstring'''

     A__	=    self._tokenizer.model.save(snake_case_     ,			name=snake_case_				)
     return tuple(snake_case_				)











"""simple docstring"""



import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..bit import BitConfig


SCREAMING_SNAKE_CASE    =	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE    =	{
    "Intel/dpt-large": "https://huggingface.co/Intel/dpt-large/resolve/main/config.json",
    # See all DPT models at https://huggingface.co/models?filter=dpt
}




class      UpperCAmelCase_  (						A_							):
    lowercase__						 =				'''dpt'''




    def __init__(   self						:	List[Any]     ,			snake_case_						:	Union[str, Any]=768     ,			snake_case_						:	Tuple=12     ,			snake_case_						:	Tuple=12     ,			snake_case_						:	List[Any]=3_072     ,			snake_case_						:	Dict="gelu"     ,			snake_case_						:	Tuple=0.0     ,			snake_case_						:	int=0.0     ,			snake_case_						:	Optional[int]=0.02     ,			snake_case_						:	Union[str, Any]=1e-12     ,			snake_case_						:	Tuple=384     ,			snake_case_						:	Tuple=16     ,			snake_case_						:	Optional[Any]=3     ,			snake_case_						:	Dict=False     ,			snake_case_						:	Any=True     ,			snake_case_						:	Any=[2, 5, 8, 11]     ,			snake_case_						:	Union[str, Any]="project"     ,			snake_case_						:	Union[str, Any]=[4, 2, 1, 0.5]     ,			snake_case_						:	List[str]=[96, 192, 384, 768]     ,			snake_case_						:	int=256     ,			snake_case_						:	Tuple=-1     ,			snake_case_						:	List[str]=False     ,			snake_case_						:	int=True     ,			snake_case_						:	List[Any]=0.4     ,			snake_case_						:	Optional[Any]=255     ,			snake_case_						:	List[str]=0.1     ,			snake_case_						:	List[str]=[1, 1_024, 24, 24]     ,			snake_case_						:	Union[str, Any]=[0, 1]     ,			snake_case_						:	Any=None     ,			**snake_case_						:	Optional[Any]     ,			)				->							Optional[int]:




     '''simple docstring'''

     super().__init__(**snake_case_				)

     A__	=    hidden_size
     A__	=    is_hybrid

     if self.is_hybrid:
      if backbone_config is None:
       logger.info("Initializing the config with a `BiT` backbone."				)
       A__	=    {
           "global_padding": "same",
           "layer_type": "bottleneck",
           "depths": [3, 4, 9],
           "out_features": ["stage1", "stage2", "stage3"],
           "embedding_dynamic_padding": True,
       }
       A__	=    BitConfig(**snake_case_				)
      elif isinstance(snake_case_     ,			snake_case_				):
       logger.info("Initializing the config with a `BiT` backbone."				)
       A__	=    BitConfig(**snake_case_				)
      elif isinstance(snake_case_     ,			snake_case_				):
       A__	=    backbone_config
      else:
       raise ValueError(
           F"""backbone_config must be a dictionary or a `PretrainedConfig`, got {backbone_config.__class__}."""				)

      A__	=    backbone_featmap_shape
      A__	=    neck_ignore_stages

      if readout_type != "project":
       raise ValueError("Readout type must be 'project' when using `DPT-hybrid` mode."				)
     else:
      A__	=    None
      A__	=    None
      A__	=    []

     A__	=    num_hidden_layers
     A__	=    num_attention_heads
     A__	=    intermediate_size
     A__	=    hidden_act
     A__	=    hidden_dropout_prob
     A__	=    attention_probs_dropout_prob
     A__	=    initializer_range
     A__	=    layer_norm_eps
     A__	=    image_size
     A__	=    patch_size
     A__	=    num_channels
     A__	=    qkv_bias
     A__	=    backbone_out_indices
     if readout_type not in ["ignore", "add", "project"]:
      raise ValueError("Readout_type must be one of ['ignore', 'add', 'project']"				)
     A__	=    readout_type
     A__	=    reassemble_factors
     A__	=    neck_hidden_sizes
     A__	=    fusion_hidden_size
     A__	=    head_in_index
     A__	=    use_batch_norm_in_fusion_residual
     # auxiliary head attributes (semantic segmentation)
     A__	=    use_auxiliary_head
     A__	=    auxiliary_loss_weight
     A__	=    semantic_loss_ignore_index
     A__	=    semantic_classifier_dropout




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




     '''simple docstring'''

     A__	=    copy.deepcopy(self.__dict__				)

     if output["backbone_config"] is not None:
      A__	=    self.backbone_config.to_dict()

     A__	=    self.__class__.model_type
     return output





