

'''simple docstring'''





import copy
import os
from typing import Union

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


UpperCAmelCase__ :     Union[str, Any]				    =    logging.get_logger(__name__)

UpperCAmelCase__ :     str				    =    {
    """microsoft/git-base""": """https://huggingface.co/microsoft/git-base/resolve/main/config.json""",
}







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : Union[str, Any]			       ="""git_vision_model"""


  def __init__(			self    : Optional[int]				,				UpperCAmelCase__    : Dict=7_6_8				,				UpperCAmelCase__    : int=3_0_7_2				,				UpperCAmelCase__    : List[str]=1_2				,				UpperCAmelCase__    : List[Any]=1_2				,				UpperCAmelCase__    : Tuple=3				,				UpperCAmelCase__    : Dict=2_2_4				,				UpperCAmelCase__    : int=1_6				,				UpperCAmelCase__    : List[str]="quick_gelu"				,				UpperCAmelCase__    : Union[str, Any]=1e-5				,				UpperCAmelCase__    : str=0.0				,				UpperCAmelCase__    : Union[str, Any]=0.02				,				**UpperCAmelCase__    : Tuple				,				)					->Dict:
        """simple docstring"""







        super().__init__(**UpperCAmelCase__		)

        SCREAMING_SNAKE_CASE :      int       =   hidden_size
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   intermediate_size
        SCREAMING_SNAKE_CASE :      Any       =   num_hidden_layers
        SCREAMING_SNAKE_CASE :      List[Any]       =   num_attention_heads
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   num_channels
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   patch_size
        SCREAMING_SNAKE_CASE :      Any       =   image_size
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   initializer_range
        SCREAMING_SNAKE_CASE :      Dict       =   attention_dropout
        SCREAMING_SNAKE_CASE :      Dict       =   layer_norm_eps
        SCREAMING_SNAKE_CASE :      Any       =   hidden_act




  @classmethod
  def  _lowercase      (			cls    : Tuple				,				UpperCAmelCase__    : Union[str, os.PathLike]				,				**UpperCAmelCase__    : Any		)					->"PretrainedConfig":
        """simple docstring"""







        cls._set_token_in_kwargs(UpperCAmelCase__		)

        SCREAMING_SNAKE_CASE :      Tuple       =   cls.get_config_dict(UpperCAmelCase__				,				**UpperCAmelCase__		)

        # get the vision config dict if we are loading from GITConfig
        if config_dict.get("""model_type"""		) == "git":
              SCREAMING_SNAKE_CASE :      Optional[int]       =   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(UpperCAmelCase__				,				**UpperCAmelCase__		)







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : Optional[int]			       ="""git"""


  def __init__(			self    : Optional[Any]				,				UpperCAmelCase__    : Optional[int]=None				,				UpperCAmelCase__    : str=3_0_5_2_2				,				UpperCAmelCase__    : Optional[int]=7_6_8				,				UpperCAmelCase__    : Union[str, Any]=6				,				UpperCAmelCase__    : List[str]=1_2				,				UpperCAmelCase__    : Tuple=3_0_7_2				,				UpperCAmelCase__    : int="gelu"				,				UpperCAmelCase__    : List[str]=0.1				,				UpperCAmelCase__    : str=0.1				,				UpperCAmelCase__    : int=1_0_2_4				,				UpperCAmelCase__    : List[str]=0.02				,				UpperCAmelCase__    : Tuple=1e-12				,				UpperCAmelCase__    : Optional[int]=0				,				UpperCAmelCase__    : str="absolute"				,				UpperCAmelCase__    : Optional[Any]=True				,				UpperCAmelCase__    : str=False				,				UpperCAmelCase__    : Optional[int]=1_0_1				,				UpperCAmelCase__    : Optional[Any]=1_0_2				,				UpperCAmelCase__    : Union[str, Any]=None				,				**UpperCAmelCase__    : List[Any]				,				)					->List[Any]:
        """simple docstring"""







        super().__init__(bos_token_id=UpperCAmelCase__				,				eos_token_id=UpperCAmelCase__				,				pad_token_id=UpperCAmelCase__				,				**UpperCAmelCase__		)

        if vision_config is None:
              SCREAMING_SNAKE_CASE :      Dict       =   {}
              logger.info("""vision_config is None. initializing the GitVisionConfig with default values."""		)

        SCREAMING_SNAKE_CASE :      int       =   GitVisionConfig(**UpperCAmelCase__		)
        SCREAMING_SNAKE_CASE :      List[Any]       =   vocab_size
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   hidden_size
        SCREAMING_SNAKE_CASE :      Optional[int]       =   num_hidden_layers
        SCREAMING_SNAKE_CASE :      Optional[int]       =   num_attention_heads
        SCREAMING_SNAKE_CASE :      Any       =   hidden_act
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   intermediate_size
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   hidden_dropout_prob
        SCREAMING_SNAKE_CASE :      int       =   attention_probs_dropout_prob
        SCREAMING_SNAKE_CASE :      List[Any]       =   max_position_embeddings
        SCREAMING_SNAKE_CASE :      Optional[int]       =   initializer_range
        SCREAMING_SNAKE_CASE :      List[Any]       =   layer_norm_eps
        SCREAMING_SNAKE_CASE :      List[str]       =   position_embedding_type
        SCREAMING_SNAKE_CASE :      int       =   use_cache
        SCREAMING_SNAKE_CASE :      str       =   tie_word_embeddings
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   num_image_with_embedding

        SCREAMING_SNAKE_CASE :      List[Any]       =   bos_token_id
        SCREAMING_SNAKE_CASE :      List[str]       =   eos_token_id




  def  _lowercase      (			self    : Optional[int]		)					->Dict:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[int]       =   copy.deepcopy(self.__dict__		)
        SCREAMING_SNAKE_CASE :      str       =   self.vision_config.to_dict()
        SCREAMING_SNAKE_CASE :      str       =   self.__class__.model_type
        return output







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
    is_vision_available,
)


UpperCAmelCase__ :     str				    =    {"""processing_layoutxlm""": ["""LayoutXLMProcessor"""]}

try:
  if not is_sentencepiece_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__ :     Any				    =    ["""LayoutXLMTokenizer"""]

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__ :     List[str]				    =    ["""LayoutXLMTokenizerFast"""]

if TYPE_CHECKING:
  from .processing_layoutxlm import LayoutXLMProcessor

  try:
    if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_layoutxlm import LayoutXLMTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_layoutxlm_fast import LayoutXLMTokenizerFast

else:
  import sys

  UpperCAmelCase__ :     List[str]				    =    _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




