


"""simple docstring"""



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      		=			{
    '''google/vit-base-patch16-224''': '''https://huggingface.co/vit-base-patch16-224/resolve/main/config.json''',
    # See all ViT models at https://huggingface.co/models?filter=vit
}
class 					__magic_name__		(			__UpperCAmelCase     ):
       __A			:      Optional[int]        =   "vit"






       def __init__(   self  :    Tuple  ,     snake_case__  :    int=7_6_8  ,     snake_case__  :    Optional[int]=1_2  ,     snake_case__  :    str=1_2  ,     snake_case__  :    Tuple=3_0_7_2  ,     snake_case__  :    Optional[int]="gelu"  ,     snake_case__  :    Optional[int]=0.0  ,     snake_case__  :    str=0.0  ,     snake_case__  :    str=0.02  ,     snake_case__  :    Union[str, Any]=1e-1_2  ,     snake_case__  :    int=2_2_4  ,     snake_case__  :    Optional[int]=1_6  ,     snake_case__  :    Optional[int]=3  ,     snake_case__  :    List[str]=True  ,     snake_case__  :    Tuple=1_6  ,     **snake_case__  :    str  ,     ):

              '''simple docstring'''






              super().__init__(**snake_case__				)

              lowercase		:Tuple       							=				hidden_size
              lowercase		:Optional[int]       							=				num_hidden_layers
              lowercase		:Optional[int]       							=				num_attention_heads
              lowercase		:Any       							=				intermediate_size
              lowercase		:Union[str, Any]       							=				hidden_act
              lowercase		:Any       							=				hidden_dropout_prob
              lowercase		:Dict       							=				attention_probs_dropout_prob
              lowercase		:Tuple       							=				initializer_range
              lowercase		:int       							=				layer_norm_eps
              lowercase		:int       							=				image_size
              lowercase		:List[Any]       							=				patch_size
              lowercase		:str       							=				num_channels
              lowercase		:Optional[int]       							=				qkv_bias
              lowercase		:Optional[Any]       							=				encoder_stride







class 					__magic_name__		(			__UpperCAmelCase     ):
       __A			:      List[str]        =   version.parse("1.11"     )






       @property
       def  __snake_case						(   self  :    Any				):

              '''simple docstring'''






              return OrderedDict(
                  [
                      ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
                  ]				)







       @property
       def  __snake_case						(   self  :    Union[str, Any]				):

              '''simple docstring'''






              return 1e-4





"""simple docstring"""



import json
from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers, processors

from ...tokenization_utils_base import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_bart import BartTokenizer


UpperCAmelCase      		=			logging.get_logger(__name__)


UpperCAmelCase      		=			{'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

# See all BART models at https://huggingface.co/models?filter=bart
UpperCAmelCase      		=			{
    '''vocab_file''': {
        '''facebook/bart-base''': '''https://huggingface.co/facebook/bart-base/resolve/main/vocab.json''',
        '''facebook/bart-large''': '''https://huggingface.co/facebook/bart-large/resolve/main/vocab.json''',
        '''facebook/bart-large-mnli''': '''https://huggingface.co/facebook/bart-large-mnli/resolve/main/vocab.json''',
        '''facebook/bart-large-cnn''': '''https://huggingface.co/facebook/bart-large-cnn/resolve/main/vocab.json''',
        '''facebook/bart-large-xsum''': '''https://huggingface.co/facebook/bart-large-xsum/resolve/main/vocab.json''',
        '''yjernite/bart_eli5''': '''https://huggingface.co/yjernite/bart_eli5/resolve/main/vocab.json''',
    },
    '''merges_file''': {
        '''facebook/bart-base''': '''https://huggingface.co/facebook/bart-base/resolve/main/merges.txt''',
        '''facebook/bart-large''': '''https://huggingface.co/facebook/bart-large/resolve/main/merges.txt''',
        '''facebook/bart-large-mnli''': '''https://huggingface.co/facebook/bart-large-mnli/resolve/main/merges.txt''',
        '''facebook/bart-large-cnn''': '''https://huggingface.co/facebook/bart-large-cnn/resolve/main/merges.txt''',
        '''facebook/bart-large-xsum''': '''https://huggingface.co/facebook/bart-large-xsum/resolve/main/merges.txt''',
        '''yjernite/bart_eli5''': '''https://huggingface.co/yjernite/bart_eli5/resolve/main/merges.txt''',
    },
    '''tokenizer_file''': {
        '''facebook/bart-base''': '''https://huggingface.co/facebook/bart-base/resolve/main/tokenizer.json''',
        '''facebook/bart-large''': '''https://huggingface.co/facebook/bart-large/resolve/main/tokenizer.json''',
        '''facebook/bart-large-mnli''': '''https://huggingface.co/facebook/bart-large-mnli/resolve/main/tokenizer.json''',
        '''facebook/bart-large-cnn''': '''https://huggingface.co/facebook/bart-large-cnn/resolve/main/tokenizer.json''',
        '''facebook/bart-large-xsum''': '''https://huggingface.co/facebook/bart-large-xsum/resolve/main/tokenizer.json''',
        '''yjernite/bart_eli5''': '''https://huggingface.co/yjernite/bart_eli5/resolve/main/tokenizer.json''',
    },
}

UpperCAmelCase      		=			{
    '''facebook/bart-base''': 1_024,
    '''facebook/bart-large''': 1_024,
    '''facebook/bart-large-mnli''': 1_024,
    '''facebook/bart-large-cnn''': 1_024,
    '''facebook/bart-large-xsum''': 1_024,
    '''yjernite/bart_eli5''': 1_024,
}
class 					__magic_name__		(			__UpperCAmelCase     ):
       __A			:      str        =   VOCAB_FILES_NAMES
       __A			:      int        =   PRETRAINED_VOCAB_FILES_MAP
       __A			:      List[Any]        =   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       __A			:      Optional[int]        =   ["input_ids", "attention_mask"]
       __A			:      List[Any]        =   BartTokenizer






       def __init__(   self  :    List[Any]  ,     snake_case__  :    Dict=None  ,     snake_case__  :    Dict=None  ,     snake_case__  :    Dict=None  ,     snake_case__  :    Optional[int]="replace"  ,     snake_case__  :    int="<s>"  ,     snake_case__  :    Optional[Any]="</s>"  ,     snake_case__  :    str="</s>"  ,     snake_case__  :    Union[str, Any]="<s>"  ,     snake_case__  :    Optional[Any]="<unk>"  ,     snake_case__  :    Tuple="<pad>"  ,     snake_case__  :    str="<mask>"  ,     snake_case__  :    List[Any]=False  ,     snake_case__  :    Tuple=True  ,     **snake_case__  :    Dict  ,     ):

              '''simple docstring'''






              super().__init__(
                  snake_case__  ,     snake_case__  ,     tokenizer_file=snake_case__  ,     errors=snake_case__  ,     bos_token=snake_case__  ,     eos_token=snake_case__  ,     sep_token=snake_case__  ,     cls_token=snake_case__  ,     unk_token=snake_case__  ,     pad_token=snake_case__  ,     mask_token=snake_case__  ,     add_prefix_space=snake_case__  ,     trim_offsets=snake_case__  ,     **snake_case__  ,     )

              lowercase		:Dict       							=				json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()				)
              if pre_tok_state.get('''add_prefix_space'''  ,     snake_case__				) != add_prefix_space:
                     lowercase		:Union[str, Any]       							=				getattr(snake_case__  ,     pre_tok_state.pop('''type'''				)				)
                     lowercase		:Tuple       							=				add_prefix_space
                     lowercase		:int       							=				pre_tok_class(**snake_case__				)

              lowercase		:str       							=				add_prefix_space

              # the pre_tokenizer is already updated in the GPT2TokenizerFast `__init__`
              lowercase		:Dict       							=				'''post_processor'''
              lowercase		:Optional[int]       							=				getattr(self.backend_tokenizer  ,     snake_case__  ,     snake_case__				)
              if tokenizer_component_instance:
                     lowercase		:Tuple       							=				json.loads(tokenizer_component_instance.__getstate__()				)

                     # The lists 'sep' and 'cls' must be cased in tuples for the object `post_processor_class`
                     if "sep" in state:
                            lowercase		:Optional[Any]       							=				tuple(state['''sep''']				)
                     if "cls" in state:
                            lowercase		:Tuple       							=				tuple(state['''cls''']				)

                     lowercase		:int       							=				False

                     if state.get('''add_prefix_space'''  ,     snake_case__				) != add_prefix_space:
                            lowercase		:Dict       							=				add_prefix_space
                            lowercase		:Optional[int]       							=				True

                     if state.get('''trim_offsets'''  ,     snake_case__				) != trim_offsets:
                            lowercase		:Any       							=				trim_offsets
                            lowercase		:Dict       							=				True

                     if changes_to_apply:
                            lowercase		:Dict       							=				getattr(snake_case__  ,     state.pop('''type'''				)				)
                            lowercase		:List[str]       							=				component_class(**snake_case__				)
                            setattr(self.backend_tokenizer  ,     snake_case__  ,     snake_case__				)






       @property
       def  __snake_case						(   self  :    Dict				):

              '''simple docstring'''






              if self._mask_token is None:
                     if self.verbose:
                            logger.error('''Using mask_token, but it is not set yet.'''				)
                     return None
              return str(self._mask_token				)






       @mask_token.setter
       def  __snake_case						(   self  :    List[Any]  ,     snake_case__  :    Optional[int]				):

              '''simple docstring'''






              lowercase		:Dict       							=				AddedToken(snake_case__  ,     lstrip=snake_case__  ,     rstrip=snake_case__				) if isinstance(snake_case__  ,     snake_case__				) else value
              lowercase		:Dict       							=				value






       def  __snake_case						(   self  :    Optional[int]  ,     *snake_case__  :    str  ,     **snake_case__  :    str				):

              '''simple docstring'''






              lowercase		:Any       							=				kwargs.get('''is_split_into_words'''  ,     snake_case__				)

              if is_split_into_words and not self.add_prefix_space:
                     raise ValueError(
                         f"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True """
                         '''to use it with pretokenized inputs.'''				)

              return super()._batch_encode_plus(*snake_case__  ,     **snake_case__				)






       def  __snake_case						(   self  :    int  ,     *snake_case__  :    int  ,     **snake_case__  :    int				):

              '''simple docstring'''






              lowercase		:Optional[int]       							=				kwargs.get('''is_split_into_words'''  ,     snake_case__				)

              if is_split_into_words and not self.add_prefix_space:
                     raise ValueError(
                         f"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True """
                         '''to use it with pretokenized inputs.'''				)

              return super()._encode_plus(*snake_case__  ,     **snake_case__				)






       def  __snake_case						(   self  :    Dict  ,     snake_case__  :    str  ,     snake_case__  :    Optional[str] = None				):

              '''simple docstring'''






              lowercase		:List[Any]       							=				self._tokenizer.model.save(snake_case__  ,     name=snake_case__				)
              return tuple(snake_case__				)






       def  __snake_case						(   self  :    int  ,     snake_case__  :    Any  ,     snake_case__  :    int=None				):

              '''simple docstring'''






              lowercase		:Any       							=				[self.bos_token_id] + token_ids_a + [self.eos_token_id]
              if token_ids_a is None:
                     return output

              return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]







       def  __snake_case						(   self  :    List[Any]  ,     snake_case__  :    List[int]  ,     snake_case__  :    Optional[List[int]] = None				):

              '''simple docstring'''






              lowercase		:int       							=				[self.sep_token_id]
              lowercase		:Tuple       							=				[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 + sep + token_ids_a + sep				) * [0]

