






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


a__       =     logging.get_logger(__name__)

a__       =     {
    """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""",
    # See all PEGASUS models at https://huggingface.co/models?filter=pegasus
}


class    _lowerCAmelCase			(		lowercase_      ):



				"""simple docstring"""



				_lowercase				:   Optional[Any]      =  '''pegasus'''
				_lowercase				:   Tuple      =  ['''past_key_values''']
				_lowercase				:   int      =  {'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}



				def __init__(      self    :    Optional[int]			,		UpperCamelCase__    :    int=5_0_2_6_5			,		UpperCamelCase__    :    Dict=1_0_2_4			,		UpperCamelCase__    :    List[str]=1_2			,		UpperCamelCase__    :    str=4_0_9_6			,		UpperCamelCase__    :    Union[str, Any]=1_6			,		UpperCamelCase__    :    Any=1_2			,		UpperCamelCase__    :    Tuple=4_0_9_6			,		UpperCamelCase__    :    Union[str, Any]=1_6			,		UpperCamelCase__    :    Optional[int]=0.0			,		UpperCamelCase__    :    List[str]=0.0			,		UpperCamelCase__    :    Any=True			,		UpperCamelCase__    :    Optional[Any]=True			,		UpperCamelCase__    :    List[str]="gelu"			,		UpperCamelCase__    :    Optional[int]=1_0_2_4			,		UpperCamelCase__    :    Optional[Any]=0.1			,		UpperCamelCase__    :    Optional[int]=0.0			,		UpperCamelCase__    :    List[Any]=0.0			,		UpperCamelCase__    :    Optional[Any]=0.02			,		UpperCamelCase__    :    Any=0			,		UpperCamelCase__    :    Tuple=False			,		UpperCamelCase__    :    List[Any]=0			,		UpperCamelCase__    :    str=1			,		UpperCamelCase__    :    Any=1			,		**UpperCamelCase__    :    str			,		):






											'''simple docstring'''







											snake_case__	  =       vocab_size
											snake_case__	  =       max_position_embeddings
											snake_case__	  =       d_model
											snake_case__	  =       encoder_ffn_dim
											snake_case__	  =       encoder_layers
											snake_case__	  =       encoder_attention_heads
											snake_case__	  =       decoder_ffn_dim
											snake_case__	  =       decoder_layers
											snake_case__	  =       decoder_attention_heads
											snake_case__	  =       dropout
											snake_case__	  =       attention_dropout
											snake_case__	  =       activation_dropout
											snake_case__	  =       activation_function
											snake_case__	  =       init_std
											snake_case__	  =       encoder_layerdrop
											snake_case__	  =       decoder_layerdrop
											snake_case__	  =       use_cache
											snake_case__	  =       encoder_layers
											snake_case__	  =       scale_embedding  # scale factor will be sqrt(d_model) if True
											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 					__magic_name__							(      self    :    Optional[int]):






											'''simple docstring'''







											return self.encoder_attention_heads



				@property
				def 					__magic_name__							(      self    :    Dict):






											'''simple docstring'''







											return self.d_model








from dataclasses import dataclass, field
from typing import Tuple

from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends
from .benchmark_args_utils import BenchmarkArguments


if is_torch_available():
	import torch

if is_torch_tpu_available(check_device=False):
	import torch_xla.core.xla_model as xm


a__       =     logging.get_logger(__name__)


@dataclass
class    _lowerCAmelCase			(		lowercase_      ):



				"""simple docstring"""



				_lowercase				:   Dict      =  [
				    '''no_inference''',
				    '''no_cuda''',
				    '''no_tpu''',
				    '''no_speed''',
				    '''no_memory''',
				    '''no_env_print''',
				    '''no_multi_process''',
				]



				def __init__(      self    :    str			,		**UpperCamelCase__    :    Dict):






											'''simple docstring'''







											for deprecated_arg in self.deprecated_args:
																		if deprecated_arg in kwargs:
																									snake_case__	  =       deprecated_arg[3:]
																									setattr(self			,		UpperCamelCase__			,		not kwargs.pop(UpperCamelCase__))
																									logger.warning(
																									    F'''{deprecated_arg} is depreciated. Please use --no_{positive_arg} or'''
																									    F''' {positive_arg}={kwargs[positive_arg]}''')

											snake_case__	  =       kwargs.pop("""torchscript"""			,		self.torchscript)
											snake_case__	  =       kwargs.pop("""torch_xla_tpu_print_metrics"""			,		self.torch_xla_tpu_print_metrics)
											snake_case__	  =       kwargs.pop("""fp16_opt_level"""			,		self.fpaa_opt_level)
											super().__init__(**UpperCamelCase__)

				_lowercase				:   bool      =  field(default=lowercase_     ,      metadata={'''help''': '''Trace the models using torchscript'''}      )
				_lowercase				:   bool      =  field(default=lowercase_     ,      metadata={'''help''': '''Print Xla/PyTorch tpu metrics'''}      )
				_lowercase				:   str      =  field(
				    default='''O1'''     ,      metadata={
				        '''help''': (
				            '''For fp16: Apex AMP optimization level selected in [\'O0\', \'O1\', \'O2\', and \'O3\']. '''
				            '''See details at https://nvidia.github.io/apex/amp.html'''
				        )
				    }     ,      )



				@cached_property
				def 					__magic_name__							(      self    :    Tuple):






											'''simple docstring'''







											requires_backends(self			,		["""torch"""])
											logger.info("""PyTorch: setting up devices""")
											if not self.cuda:
																		snake_case__	  =       torch.device("""cpu""")
																		snake_case__	  =       0
											elif is_torch_tpu_available():
																		snake_case__	  =       xm.xla_device()
																		snake_case__	  =       0
											else:
																		snake_case__	  =       torch.device("""cuda""" if torch.cuda.is_available() else """cpu""")
																		snake_case__	  =       torch.cuda.device_count()
											return device, n_gpu



				@property
				def 					__magic_name__							(      self    :    Union[str, Any]):






											'''simple docstring'''







											return is_torch_tpu_available() and self.tpu



				@property
				def 					__magic_name__							(      self    :    List[str]):






											'''simple docstring'''







											requires_backends(self			,		["""torch"""])
											# TODO(PVP): currently only single GPU is supported
											return torch.cuda.current_device()



				@property
				def 					__magic_name__							(      self    :    Union[str, Any]):






											'''simple docstring'''







											requires_backends(self			,		["""torch"""])
											return self._setup_devices[0]



				@property
				def 					__magic_name__							(      self    :    str):






											'''simple docstring'''







											requires_backends(self			,		["""torch"""])
											return self._setup_devices[1]



				@property
				def 					__magic_name__							(      self    :    str):






											'''simple docstring'''







											return self.n_gpu > 0
