


'''simple docstring'''
__magic_name__ : Optional[int]					=6_55_21




def   __snake_case							(							lowerCamelCase_			:					Optional[Any]    ):
				'''simple docstring'''




				__magic_name__							=			1
				__magic_name__							=			0
				for plain_chr in plain_text:
								__magic_name__							=			(a + ord(lowerCamelCase_    )) % MOD_ADLER
								__magic_name__							=			(b + a) % MOD_ADLER
				return (b << 16) | a





import copy
import os
from typing import Union

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


lowerCamelCase__						=				logging.get_logger(__name__)

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







class 							lowerCAmelCase__   ( __lowercase						):
						UpperCamelCase_				:			Union[str, Any]						=		"pix2struct_text_model"
						UpperCamelCase_				:			str						=		["past_key_values"]
						UpperCamelCase_				:			str						=		{
						    "hidden_size": "hidden_size",
						    "num_attention_heads": "num_heads",
						    "num_hidden_layers": "num_layers",
						}

						def __init__(      self							,				a=5_02_44							,				a=7_68							,				a=64							,				a=20_48							,				a=12							,				a=12							,				a=32							,				a=1_28							,				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							,				)       ->   Optional[int]:


								'''simple docstring'''

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

								_UpperCamelCase         =						eos_token_id
								_UpperCamelCase         =						decoder_start_token_id

								# for backwards compatibility
								_UpperCamelCase         =						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					)       ->   "PretrainedConfig":


								'''simple docstring'''

								cls._set_token_in_kwargs(a					)

								_UpperCamelCase     ,						_UpperCamelCase         =						cls.get_config_dict(a							,				**a					)

								# get the text config dict if we are loading from Pix2StructConfig
								if config_dict.get("""model_type"""					) == "pix2struct":
										_UpperCamelCase         =						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 							lowerCAmelCase__   ( __lowercase						):
						UpperCamelCase_				:			int						=		"pix2struct_vision_model"

						def __init__(      self							,				a=7_68							,				a=7_68							,				a=20_48							,				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=40_96							,				a=32							,				a=1_28							,				**a							,				)       ->   Tuple:


								'''simple docstring'''

								super().__init__(**a					)

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







						@classmethod
						def 			A_					(      cls							,				a							,				**a					)       ->   "PretrainedConfig":


								'''simple docstring'''

								cls._set_token_in_kwargs(a					)

								_UpperCamelCase     ,						_UpperCamelCase         =						cls.get_config_dict(a							,				**a					)

								# get the vision config dict if we are loading from Pix2StructConfig
								if config_dict.get("""model_type"""					) == "pix2struct":
										_UpperCamelCase         =						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 							lowerCAmelCase__   ( __lowercase						):
						UpperCamelCase_				:			Dict						=		"pix2struct"
						UpperCamelCase_				:			int						=		True

						def __init__(      self							,				a=None							,				a=None							,				a=1.0							,				a=0.02							,				a=False							,				a=False							,				a=True							,				**a							,				)       ->   Optional[Any]:


								'''simple docstring'''

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

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

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

								_UpperCamelCase         =						PixaStructTextConfig(**a					)
								_UpperCamelCase         =						PixaStructVisionConfig(**a					)

								_UpperCamelCase         =						self.text_config.decoder_start_token_id
								_UpperCamelCase         =						self.text_config.pad_token_id
								_UpperCamelCase         =						self.text_config.eos_token_id

								_UpperCamelCase         =						initializer_factor
								_UpperCamelCase         =						initializer_range

								_UpperCamelCase         =						self.initializer_range
								_UpperCamelCase         =						self.initializer_range

								_UpperCamelCase         =						is_vqa

						@classmethod
						def 			A_					(      cls							,				a							,				a							,				**a					)       ->   str:


								'''simple docstring'''

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







						def 			A_					(      self					)       ->   Union[str, Any]:


								'''simple docstring'''

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



