




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


_lowerCamelCase					:     int					  =  logging.get_logger(__name__)

_lowerCamelCase					:     Optional[Any]					  =  {
    "google/pegasus-x-base": "https://huggingface.co/google/pegasus-x-base/resolve/main/config.json",
    "google/pegasus-x-large": "https://huggingface.co/google/pegasus-x-large/resolve/main/config.json",
    # See all PEGASUS-X models at https://huggingface.co/models?filter=pegasus-x
}
class 				__snake_case     (_a						):
				lowerCAmelCase__			=   "pegasus_x"
				lowerCAmelCase__			=   ["past_key_values"]
				lowerCAmelCase__			=   {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}



				def __init__(					self					:						List[Any]						,		_UpperCAmelCase					:						List[str]=9_6103						,		_UpperCAmelCase					:						Optional[Any]=1_6384						,		_UpperCAmelCase					:						Union[str, Any]=16						,		_UpperCAmelCase					:						Tuple=4096						,		_UpperCAmelCase					:						Any=16						,		_UpperCAmelCase					:						Optional[int]=16						,		_UpperCAmelCase					:						Optional[Any]=4096						,		_UpperCAmelCase					:						Optional[int]=16						,		_UpperCAmelCase					:						List[str]=0.0						,		_UpperCAmelCase					:						Union[str, Any]=0.0						,		_UpperCAmelCase					:						Any=True						,		_UpperCAmelCase					:						List[Any]=True						,		_UpperCAmelCase					:						Tuple="gelu"						,		_UpperCAmelCase					:						Any=1024						,		_UpperCAmelCase					:						Any=0.1						,		_UpperCAmelCase					:						Tuple=0.0						,		_UpperCAmelCase					:						Optional[Any]=0.0						,		_UpperCAmelCase					:						Dict=0.02						,		_UpperCAmelCase					:						Dict=0						,		_UpperCAmelCase					:						List[str]=True						,		_UpperCAmelCase					:						str=0						,		_UpperCAmelCase					:						List[str]=1						,		_UpperCAmelCase					:						str=1						,		_UpperCAmelCase					:						str=32						,		_UpperCAmelCase					:						Union[str, Any]=512						,		_UpperCAmelCase					:						List[str]=True						,		**_UpperCAmelCase					:						Optional[int]						,		)     ->			Tuple:





								'''simple docstring'''




								_lowerCAmelCase			:			Any        =					vocab_size
								_lowerCAmelCase			:			Dict        =					max_position_embeddings
								_lowerCAmelCase			:			int        =					d_model
								_lowerCAmelCase			:			Any        =					encoder_ffn_dim
								_lowerCAmelCase			:			List[Any]        =					encoder_layers
								_lowerCAmelCase			:			Any        =					encoder_attention_heads
								_lowerCAmelCase			:			List[str]        =					decoder_ffn_dim
								_lowerCAmelCase			:			Optional[int]        =					decoder_layers
								_lowerCAmelCase			:			Optional[Any]        =					decoder_attention_heads
								_lowerCAmelCase			:			Optional[Any]        =					dropout
								_lowerCAmelCase			:			str        =					attention_dropout
								_lowerCAmelCase			:			str        =					activation_dropout
								_lowerCAmelCase			:			Optional[int]        =					activation_function
								_lowerCAmelCase			:			List[Any]        =					init_std
								_lowerCAmelCase			:			Dict        =					encoder_layerdrop
								_lowerCAmelCase			:			Union[str, Any]        =					decoder_layerdrop
								_lowerCAmelCase			:			Optional[Any]        =					use_cache
								_lowerCAmelCase			:			Optional[Any]        =					encoder_layers
								_lowerCAmelCase			:			Dict        =					scale_embedding  # scale factor will be sqrt(d_model) if True

								_lowerCAmelCase			:			Optional[int]        =					num_global_tokens
								_lowerCAmelCase			:			Tuple        =					block_size
								_lowerCAmelCase			:			Optional[int]        =					stagger_local_blocks

								super().__init__(
								    pad_token_id=_UpperCAmelCase						,		eos_token_id=_UpperCAmelCase						,		is_encoder_decoder=_UpperCAmelCase						,		decoder_start_token_id=_UpperCAmelCase						,		forced_eos_token_id=_UpperCAmelCase						,		**_UpperCAmelCase						,		)



				@property
				def 					SCREAMING_SNAKE_CASE				(					self					:						Optional[Any]					)     ->			int:





								'''simple docstring'''




								return self.encoder_attention_heads



				@property
				def 					SCREAMING_SNAKE_CASE				(					self					:						Union[str, Any]					)     ->			int:





								'''simple docstring'''




								return self.d_model




import importlib.metadata
import subprocess
import sys





def 	snake_case_      (__A     :						bool = False     )			->	str:
   __lowerCAmelCase  :			Any					    =						False
   if "IPython" in sys.modules:
      __lowerCAmelCase  :			Optional[int]					    =						"""google.colab""" in str(sys.modules["""IPython"""].get_ipython()     )

   if in_colab:
      if upgrade:
         __lowerCAmelCase  :			int					    =						["""pip""", """install""", """-U""", """torch"""]
         subprocess.run(__A					,   check=__A     )
      # get the current version of torch
      __lowerCAmelCase  :			List[Any]					    =						importlib.metadata.version("""torch"""     )
      __lowerCAmelCase  :			List[Any]					    =						torch_version[: torch_version.rindex("""."""     )]
      __lowerCAmelCase  :			int					    =						f'''https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-{torch_version_trunc}-cp37-cp37m-linux_x86_64.whl'''
      __lowerCAmelCase  :			List[Any]					    =						["""pip""", """install""", xla_wheel]
      subprocess.run(__A					,   check=__A     )
   else:
      raise RuntimeError("""`install_xla` utility works only on google colab."""     )


