






import copy
import os
from typing import Union

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


A_		:		Any		     =			logging.get_logger(__name__)

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




class     _lowerCAmelCase(	lowerCamelCase_ ):





							"""simple docstring"""







							a    :		Dict									="""pix2struct_text_model"""
							a    :		str									=["""past_key_values"""]
							a    :		Dict									={
							    """hidden_size""": """hidden_size""",
							    """num_attention_heads""": """num_heads""",
							    """num_hidden_layers""": """num_layers""",
							}





							def __init__( self  ,      _lowerCamelCase=5_0_2_4_4  ,      _lowerCamelCase=7_6_8  ,      _lowerCamelCase=6_4  ,      _lowerCamelCase=2_0_4_8  ,      _lowerCamelCase=1_2  ,      _lowerCamelCase=1_2  ,      _lowerCamelCase=3_2  ,      _lowerCamelCase=1_2_8  ,      _lowerCamelCase=0.1  ,      _lowerCamelCase=1e-6  ,      _lowerCamelCase=1.0  ,      _lowerCamelCase="gelu_new"  ,      _lowerCamelCase=0  ,      _lowerCamelCase=False  ,      _lowerCamelCase=0  ,      _lowerCamelCase=1  ,      _lowerCamelCase=False  ,      _lowerCamelCase=True  ,      **_lowerCamelCase  ,      ):
									UpperCamelCase_: Optional[Any]   				=    vocab_size
									UpperCamelCase_: List[str]   				=    hidden_size
									UpperCamelCase_: Optional[int]   				=    d_kv
									UpperCamelCase_: Tuple   				=    d_ff
									UpperCamelCase_: Dict   				=    num_layers
									UpperCamelCase_: Any   				=    num_heads
									UpperCamelCase_: Optional[Any]   				=    relative_attention_num_buckets
									UpperCamelCase_: Optional[Any]   				=    relative_attention_max_distance
									UpperCamelCase_: List[Any]   				=    dropout_rate
									UpperCamelCase_: str   				=    layer_norm_epsilon
									UpperCamelCase_: Dict   				=    initializer_factor
									UpperCamelCase_: Tuple   				=    use_cache

									UpperCamelCase_: Dict   				=    eos_token_id
									UpperCamelCase_: Optional[Any]   				=    decoder_start_token_id

									# for backwards compatibility
									UpperCamelCase_: Any   				=    dense_act_fn

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





							@classmethod
							def       _a   ( cls  ,      _lowerCamelCase  ,      **_lowerCamelCase							):
									cls._set_token_in_kwargs(_UpperCAmelCase							)

									UpperCamelCase_				,UpperCamelCase_: int   				=    cls.get_config_dict(_UpperCAmelCase  ,      **_UpperCAmelCase							)

									# get the text config dict if we are loading from Pix2StructConfig
									if config_dict.get('model_type'							) == "pix2struct":
											UpperCamelCase_: Optional[Any]   				=    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(_UpperCAmelCase  ,      **_UpperCAmelCase							)







class     _lowerCAmelCase(	lowerCamelCase_ ):





							"""simple docstring"""







							a    :		Optional[int]									="""pix2struct_vision_model"""





							def __init__( self  ,      _lowerCamelCase=7_6_8  ,      _lowerCamelCase=7_6_8  ,      _lowerCamelCase=2_0_4_8  ,      _lowerCamelCase=6_4  ,      _lowerCamelCase=1_2  ,      _lowerCamelCase=1_2  ,      _lowerCamelCase="gelu_new"  ,      _lowerCamelCase=1e-6  ,      _lowerCamelCase=0.0  ,      _lowerCamelCase=0.0  ,      _lowerCamelCase=1e-10  ,      _lowerCamelCase=1.0  ,      _lowerCamelCase=4_0_9_6  ,      _lowerCamelCase=3_2  ,      _lowerCamelCase=1_2_8  ,      **_lowerCamelCase  ,      ):
									super().__init__(**_UpperCAmelCase							)

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





							@classmethod
							def       _a   ( cls  ,      _lowerCamelCase  ,      **_lowerCamelCase							):
									cls._set_token_in_kwargs(_UpperCAmelCase							)

									UpperCamelCase_				,UpperCamelCase_: Any   				=    cls.get_config_dict(_UpperCAmelCase  ,      **_UpperCAmelCase							)

									# get the vision config dict if we are loading from Pix2StructConfig
									if config_dict.get('model_type'							) == "pix2struct":
											UpperCamelCase_: 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(_UpperCAmelCase  ,      **_UpperCAmelCase							)







class     _lowerCAmelCase(	lowerCamelCase_ ):





							"""simple docstring"""







							a    :		str									="""pix2struct"""
							a    :		Union[str, Any]									=True





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

									if text_config is None:
											UpperCamelCase_: Optional[Any]   				=    {}
											logger.info('text_config is None. Initializing the Pix2StructTextConfig with default values.'							)

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

									UpperCamelCase_: List[str]   				=    PixaStructTextConfig(**_UpperCAmelCase							)
									UpperCamelCase_: Union[str, Any]   				=    PixaStructVisionConfig(**_UpperCAmelCase							)

									UpperCamelCase_: List[Any]   				=    self.text_config.decoder_start_token_id
									UpperCamelCase_: Tuple   				=    self.text_config.pad_token_id
									UpperCamelCase_: Tuple   				=    self.text_config.eos_token_id

									UpperCamelCase_: List[str]   				=    initializer_factor
									UpperCamelCase_: List[str]   				=    initializer_range

									UpperCamelCase_: List[str]   				=    self.initializer_range
									UpperCamelCase_: List[Any]   				=    self.initializer_range

									UpperCamelCase_: int   				=    is_vqa





							@classmethod
							def       _a   ( cls  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      **_lowerCamelCase							):
									return cls(text_config=text_config.to_dict()  ,      vision_config=vision_config.to_dict()  ,      **_UpperCAmelCase							)





							def       _a   ( self							):
									UpperCamelCase_: Dict   				=    copy.deepcopy(self.__dict__							)
									UpperCamelCase_: Optional[int]   				=    self.text_config.to_dict()
									UpperCamelCase_: int   				=    self.vision_config.to_dict()
									UpperCamelCase_: List[str]   				=    self.__class__.model_type
									return output







def   snake_case (UpperCAmelCase__  )	->    int:
  assert isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ), F'''The input value of [n={number}] is not an integer'''

  if number == 1:
    return 2
  elif number < 1:
    UpperCamelCase_: List[Any]   				=    F'''The input value of [n={number}] has to be > 0'''
    raise ValueError(UpperCAmelCase__  )
  else:
    UpperCamelCase_: str   				=    sylvester(number - 1  )
    UpperCamelCase_: str   				=    num - 1
    UpperCamelCase_: Any   				=    num
    return lower * upper + 1


if __name__ == "__main__":
   print(F'''The 8th number in Sylvester\'s sequence: {sylvester(8)}''')