

import copy
import os
from typing import Union

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


lowercase_       		=  logging.get_logger(__name__)

lowercase_       		=  {
    "google/pix2struct-textcaps-base": (
        "https://huggingface.co/google/pix2struct-textcaps-base/resolve/main/config.json"
    ),
}


class  A						(							_UpperCAmelCase ):







    """simple docstring"""





    lowerCamelCase			=							'pix2struct_text_model'
    lowerCamelCase			=							['past_key_values']
    lowerCamelCase			=							{
        'hidden_size': 'hidden_size',
        'num_attention_heads': 'num_heads',
        'num_hidden_layers': 'num_layers',
    }


    def __init__(      self :       List[Any],lowercase_ :       Union[str, Any]=5_0_2_4_4,lowercase_ :       Optional[int]=7_6_8,lowercase_ :       Tuple=6_4,lowercase_ :       Optional[Any]=2_0_4_8,lowercase_ :       Tuple=1_2,lowercase_ :       List[Any]=1_2,lowercase_ :       Union[str, Any]=3_2,lowercase_ :       Any=1_2_8,lowercase_ :       Optional[int]=0.1,lowercase_ :       Tuple=1E-6,lowercase_ :       List[str]=1.0,lowercase_ :       str="gelu_new",lowercase_ :       int=0,lowercase_ :       Union[str, Any]=False,lowercase_ :       Tuple=0,lowercase_ :       Optional[Any]=1,lowercase_ :       List[Any]=False,lowercase_ :       Any=True,**lowercase_ :       Dict,)->    int:





        '''simple docstring'''







        A__          =   vocab_size
        A__          =   hidden_size
        A__          =   d_kv
        A__          =   d_ff
        A__          =   num_layers
        A__          =   num_heads
        A__          =   relative_attention_num_buckets
        A__          =   relative_attention_max_distance
        A__          =   dropout_rate
        A__          =   layer_norm_epsilon
        A__          =   initializer_factor
        A__          =   use_cache

        A__          =   eos_token_id
        A__          =   decoder_start_token_id

        # for backwards compatibility
        A__          =   dense_act_fn

        super().__init__(
            pad_token_id=lowercase_,eos_token_id=lowercase_,decoder_start_token_id=lowercase_,tie_word_embeddings=lowercase_,is_decoder=lowercase_,**lowercase_,)


    @classmethod
    def 						snake_case__     (      cls :       str,lowercase_ :       Union[str, os.PathLike],**lowercase_ :       int		)->    "PretrainedConfig":





        '''simple docstring'''







        cls._set_token_in_kwargs(lowercase_		)

        A__      ,						A__          =   cls.get_config_dict(lowercase_,**lowercase_		)

        # get the text config dict if we are loading from Pix2StructConfig
        if config_dict.get('model_type'		) == "pix2struct":
            A__          =   config_dict['text_config']

        if "model_type" in config_dict and hasattr(cls,'model_type'		) and config_dict["model_type"] != cls.model_type:
            logger.warning(
                F'You are using a model of type {config_dict["model_type"]} to instantiate a model of type '
                F'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'		)

        return cls.from_dict(lowercase_,**lowercase_		)




class  A						(							_UpperCAmelCase ):







    """simple docstring"""





    lowerCamelCase			=							'pix2struct_vision_model'


    def __init__(      self :       int,lowercase_ :       str=7_6_8,lowercase_ :       Optional[Any]=7_6_8,lowercase_ :       Dict=2_0_4_8,lowercase_ :       List[Any]=6_4,lowercase_ :       int=1_2,lowercase_ :       List[str]=1_2,lowercase_ :       List[Any]="gelu_new",lowercase_ :       List[str]=1E-6,lowercase_ :       Optional[Any]=0.0,lowercase_ :       Optional[Any]=0.0,lowercase_ :       Union[str, Any]=1E-10,lowercase_ :       Optional[Any]=1.0,lowercase_ :       List[Any]=4_0_9_6,lowercase_ :       Union[str, Any]=3_2,lowercase_ :       Dict=1_2_8,**lowercase_ :       Dict,)->    List[Any]:





        '''simple docstring'''







        super().__init__(**lowercase_		)

        A__          =   hidden_size
        A__          =   patch_embed_hidden_size
        A__          =   d_ff
        A__          =   dropout_rate
        A__          =   num_hidden_layers
        A__          =   num_attention_heads
        A__          =   initializer_range
        A__          =   initializer_factor
        A__          =   attention_dropout
        A__          =   layer_norm_eps
        A__          =   dense_act_fn
        A__          =   seq_len
        A__          =   relative_attention_num_buckets
        A__          =   relative_attention_max_distance
        A__          =   d_kv


    @classmethod
    def 						snake_case__     (      cls :       List[str],lowercase_ :       Union[str, os.PathLike],**lowercase_ :       Dict		)->    "PretrainedConfig":





        '''simple docstring'''







        cls._set_token_in_kwargs(lowercase_		)

        A__      ,						A__          =   cls.get_config_dict(lowercase_,**lowercase_		)

        # get the vision config dict if we are loading from Pix2StructConfig
        if config_dict.get('model_type'		) == "pix2struct":
            A__          =   config_dict['vision_config']

        if "model_type" in config_dict and hasattr(cls,'model_type'		) and config_dict["model_type"] != cls.model_type:
            logger.warning(
                F'You are using a model of type {config_dict["model_type"]} to instantiate a model of type '
                F'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'		)

        return cls.from_dict(lowercase_,**lowercase_		)




class  A						(							_UpperCAmelCase ):







    """simple docstring"""





    lowerCamelCase			=							'pix2struct'
    lowerCamelCase			=							True


    def __init__(      self :       Any,lowercase_ :       Tuple=None,lowercase_ :       List[str]=None,lowercase_ :       Optional[int]=1.0,lowercase_ :       Optional[int]=0.02,lowercase_ :       Tuple=False,lowercase_ :       int=False,lowercase_ :       Any=True,**lowercase_ :       Tuple,)->    Any:





        '''simple docstring'''







        super().__init__(tie_word_embeddings=lowercase_,is_encoder_decoder=lowercase_,**lowercase_		)

        if text_config is None:
            A__          =   {}
            logger.info('text_config is None. Initializing the Pix2StructTextConfig with default values.'		)

        if vision_config is None:
            A__          =   {}
            logger.info('vision_config is None. Initializing the Pix2StructVisionConfig with default values.'		)

        A__          =   PixaStructTextConfig(**lowercase_		)
        A__          =   PixaStructVisionConfig(**lowercase_		)

        A__          =   self.text_config.decoder_start_token_id
        A__          =   self.text_config.pad_token_id
        A__          =   self.text_config.eos_token_id

        A__          =   initializer_factor
        A__          =   initializer_range

        A__          =   self.initializer_range
        A__          =   self.initializer_range

        A__          =   is_vqa


    @classmethod
    def 						snake_case__     (      cls :       List[Any],lowercase_ :       PixaStructTextConfig,lowercase_ :       PixaStructVisionConfig,**lowercase_ :       int		)->    Dict:





        '''simple docstring'''







        return cls(text_config=text_config.to_dict(),vision_config=vision_config.to_dict(),**lowercase_		)


    def 						snake_case__     (      self :       Tuple		)->    Any:





        '''simple docstring'''







        A__          =   copy.deepcopy(self.__dict__		)
        A__          =   self.text_config.to_dict()
        A__          =   self.vision_config.to_dict()
        A__          =   self.__class__.model_type
        return output





'''simple docstring'''
from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCamelCase__    					=      {
    '''configuration_distilbert''': [
        '''DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''DistilBertConfig''',
        '''DistilBertOnnxConfig''',
    ],
    '''tokenization_distilbert''': ['''DistilBertTokenizer'''],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      ['''DistilBertTokenizerFast''']

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      [
      '''DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''DistilBertForMaskedLM''',
      '''DistilBertForMultipleChoice''',
      '''DistilBertForQuestionAnswering''',
      '''DistilBertForSequenceClassification''',
      '''DistilBertForTokenClassification''',
      '''DistilBertModel''',
      '''DistilBertPreTrainedModel''',
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      [
      '''TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''TFDistilBertForMaskedLM''',
      '''TFDistilBertForMultipleChoice''',
      '''TFDistilBertForQuestionAnswering''',
      '''TFDistilBertForSequenceClassification''',
      '''TFDistilBertForTokenClassification''',
      '''TFDistilBertMainLayer''',
      '''TFDistilBertModel''',
      '''TFDistilBertPreTrainedModel''',
  ]

try:
  if not is_flax_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      [
      '''FlaxDistilBertForMaskedLM''',
      '''FlaxDistilBertForMultipleChoice''',
      '''FlaxDistilBertForQuestionAnswering''',
      '''FlaxDistilBertForSequenceClassification''',
      '''FlaxDistilBertForTokenClassification''',
      '''FlaxDistilBertModel''',
      '''FlaxDistilBertPreTrainedModel''',
  ]


if TYPE_CHECKING:
  from .configuration_distilbert import (
      DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
      DistilBertConfig,
      DistilBertOnnxConfig,
  )
  from .tokenization_distilbert import DistilBertTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_distilbert_fast import DistilBertTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_distilbert import (
        DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        DistilBertForMaskedLM,
        DistilBertForMultipleChoice,
        DistilBertForQuestionAnswering,
        DistilBertForSequenceClassification,
        DistilBertForTokenClassification,
        DistilBertModel,
        DistilBertPreTrainedModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_distilbert import (
        TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFDistilBertForMaskedLM,
        TFDistilBertForMultipleChoice,
        TFDistilBertForQuestionAnswering,
        TFDistilBertForSequenceClassification,
        TFDistilBertForTokenClassification,
        TFDistilBertMainLayer,
        TFDistilBertModel,
        TFDistilBertPreTrainedModel,
    )

  try:
    if not is_flax_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_flax_distilbert import (
        FlaxDistilBertForMaskedLM,
        FlaxDistilBertForMultipleChoice,
        FlaxDistilBertForQuestionAnswering,
        FlaxDistilBertForSequenceClassification,
        FlaxDistilBertForTokenClassification,
        FlaxDistilBertModel,
        FlaxDistilBertPreTrainedModel,
    )

else:
  import sys

  UpperCamelCase__    					=      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
