"""simple docstring"""




import copy
import os
from typing import Union

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


_a				:		str	   =       logging.get_logger(__name__)

_a				:		Tuple	   =       {
    'google/pix2struct-textcaps-base': (
        'https://huggingface.co/google/pix2struct-textcaps-base/resolve/main/config.json'
    ),
}
class 						__A							(			SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Optional[Any]		 =		"pix2struct_text_model"
     _UpperCamelCase							:      Optional[int]		 =		["past_key_values"]
     _UpperCamelCase							:      Union[str, Any]		 =		{
         "hidden_size": "hidden_size",
         "num_attention_heads": "num_heads",
         "num_hidden_layers": "num_layers",
     }






     def __init__(		self    ,					a__=50244    ,					a__=768    ,					a__=64    ,					a__=2048    ,					a__=12    ,					a__=12    ,					a__=32    ,					a__=128    ,					a__=0.1    ,					a__=1e-6    ,					a__=1.0    ,					a__="gelu_new"    ,					a__=0    ,					a__=False    ,					a__=0    ,					a__=1    ,					a__=False    ,					a__=True    ,					**a__    ,					):
       _lowerCAmelCase						:	Dict        =					vocab_size
       _lowerCAmelCase						:	str        =					hidden_size
       _lowerCAmelCase						:	Optional[Any]        =					d_kv
       _lowerCAmelCase						:	Tuple        =					d_ff
       _lowerCAmelCase						:	Any        =					num_layers
       _lowerCAmelCase						:	Tuple        =					num_heads
       _lowerCAmelCase						:	Union[str, Any]        =					relative_attention_num_buckets
       _lowerCAmelCase						:	List[Any]        =					relative_attention_max_distance
       _lowerCAmelCase						:	Union[str, Any]        =					dropout_rate
       _lowerCAmelCase						:	Union[str, Any]        =					layer_norm_epsilon
       _lowerCAmelCase						:	Optional[int]        =					initializer_factor
       _lowerCAmelCase						:	Optional[Any]        =					use_cache

       _lowerCAmelCase						:	Tuple        =					eos_token_id
       _lowerCAmelCase						:	Tuple        =					decoder_start_token_id

       # for backwards compatibility
       _lowerCAmelCase						:	Dict        =					dense_act_fn

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






     @classmethod
     def    __A  (		cls    ,					a__    ,					**a__  ):
       cls._set_token_in_kwargs(a__  )

       _lowerCAmelCase      ,     _lowerCAmelCase						:	str        =					cls.get_config_dict(a__    ,					**a__  )

       # get the text config dict if we are loading from Pix2StructConfig
       if config_dict.get("""model_type"""  ) == "pix2struct":
         _lowerCAmelCase						:	List[str]        =					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(a__    ,					**a__  )







class 						__A							(			SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      List[str]		 =		"pix2struct_vision_model"






     def __init__(		self    ,					a__=768    ,					a__=768    ,					a__=2048    ,					a__=64    ,					a__=12    ,					a__=12    ,					a__="gelu_new"    ,					a__=1e-6    ,					a__=0.0    ,					a__=0.0    ,					a__=1e-10    ,					a__=1.0    ,					a__=4096    ,					a__=32    ,					a__=128    ,					**a__    ,					):
       super().__init__(**a__  )

       _lowerCAmelCase						:	int        =					hidden_size
       _lowerCAmelCase						:	Any        =					patch_embed_hidden_size
       _lowerCAmelCase						:	int        =					d_ff
       _lowerCAmelCase						:	str        =					dropout_rate
       _lowerCAmelCase						:	int        =					num_hidden_layers
       _lowerCAmelCase						:	Any        =					num_attention_heads
       _lowerCAmelCase						:	Optional[int]        =					initializer_range
       _lowerCAmelCase						:	List[str]        =					initializer_factor
       _lowerCAmelCase						:	Dict        =					attention_dropout
       _lowerCAmelCase						:	str        =					layer_norm_eps
       _lowerCAmelCase						:	Optional[int]        =					dense_act_fn
       _lowerCAmelCase						:	str        =					seq_len
       _lowerCAmelCase						:	Tuple        =					relative_attention_num_buckets
       _lowerCAmelCase						:	List[str]        =					relative_attention_max_distance
       _lowerCAmelCase						:	int        =					d_kv






     @classmethod
     def    __A  (		cls    ,					a__    ,					**a__  ):
       cls._set_token_in_kwargs(a__  )

       _lowerCAmelCase      ,     _lowerCAmelCase						:	Dict        =					cls.get_config_dict(a__    ,					**a__  )

       # get the vision config dict if we are loading from Pix2StructConfig
       if config_dict.get("""model_type"""  ) == "pix2struct":
         _lowerCAmelCase						:	List[str]        =					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(a__    ,					**a__  )







class 						__A							(			SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Optional[Any]		 =		"pix2struct"
     _UpperCamelCase							:      List[str]		 =		True






     def __init__(		self    ,					a__=None    ,					a__=None    ,					a__=1.0    ,					a__=0.0_2    ,					a__=False    ,					a__=False    ,					a__=True    ,					**a__    ,					):
       super().__init__(tie_word_embeddings=a__    ,					is_encoder_decoder=a__    ,					**a__  )

       if text_config is None:
         _lowerCAmelCase						:	str        =					{}
         logger.info("""text_config is None. Initializing the Pix2StructTextConfig with default values."""  )

       if vision_config is None:
         _lowerCAmelCase						:	Union[str, Any]        =					{}
         logger.info("""vision_config is None. Initializing the Pix2StructVisionConfig with default values."""  )

       _lowerCAmelCase						:	List[Any]        =					PixaStructTextConfig(**a__  )
       _lowerCAmelCase						:	Dict        =					PixaStructVisionConfig(**a__  )

       _lowerCAmelCase						:	Optional[Any]        =					self.text_config.decoder_start_token_id
       _lowerCAmelCase						:	Dict        =					self.text_config.pad_token_id
       _lowerCAmelCase						:	List[str]        =					self.text_config.eos_token_id

       _lowerCAmelCase						:	Union[str, Any]        =					initializer_factor
       _lowerCAmelCase						:	int        =					initializer_range

       _lowerCAmelCase						:	Optional[Any]        =					self.initializer_range
       _lowerCAmelCase						:	Tuple        =					self.initializer_range

       _lowerCAmelCase						:	Dict        =					is_vqa






     @classmethod
     def    __A  (		cls    ,					a__    ,					a__    ,					**a__  ):
       return cls(text_config=text_config.to_dict()    ,					vision_config=vision_config.to_dict()    ,					**a__  )






     def    __A  (		self  ):
       _lowerCAmelCase						:	Union[str, Any]        =					copy.deepcopy(self.__dict__  )
       _lowerCAmelCase						:	Union[str, Any]        =					self.text_config.to_dict()
       _lowerCAmelCase						:	Union[str, Any]        =					self.vision_config.to_dict()
       _lowerCAmelCase						:	Tuple        =					self.__class__.model_type
       return output





"""simple docstring"""




from ..utils import DummyObject, requires_backends
class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Optional[Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      List[Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      int		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      str		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Optional[int]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      List[Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      str		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Union[str, Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Optional[int]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      List[str]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Any		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      str		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Tuple		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      str		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Tuple		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      str		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Tuple		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      str		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Dict		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Dict		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Union[str, Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Tuple		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      List[Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Optional[int]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Optional[Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Optional[Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      List[Any]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      int		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Dict		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      List[str]		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )







class 						__A							(			metaclass=SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      int		 =		["sentencepiece"]






     def __init__(		self    ,					*a__    ,					**a__  ):
       requires_backends(self    ,					["""sentencepiece"""]  )




