





"""simple docstring"""






from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import TensorType, logging


if TYPE_CHECKING:
		from ...onnx.config import PatchingSpec
		from ...tokenization_utils_base import PreTrainedTokenizerBase


A			      =	logging.get_logger(__name__)

A			      =	{
    '''allenai/longformer-base-4096''': '''https://huggingface.co/allenai/longformer-base-4096/resolve/main/config.json''',
    '''allenai/longformer-large-4096''': '''https://huggingface.co/allenai/longformer-large-4096/resolve/main/config.json''',
    '''allenai/longformer-large-4096-finetuned-triviaqa''': (
        '''https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/config.json'''
    ),
    '''allenai/longformer-base-4096-extra.pos.embd.only''': (
        '''https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/config.json'''
    ),
    '''allenai/longformer-large-4096-extra.pos.embd.only''': (
        '''https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/config.json'''
    ),
}




class 					__lowercase      (      _UpperCamelCase				):







					'''simple docstring'''




					__lowerCAmelCase	=	'''longformer'''







					def __init__(    self						,      _UpperCAmelCase = 512						,      _UpperCAmelCase = 2						,      _UpperCAmelCase = 1						,      _UpperCAmelCase = 0						,      _UpperCAmelCase = 2						,      _UpperCAmelCase = 30522						,      _UpperCAmelCase = 768						,      _UpperCAmelCase = 12						,      _UpperCAmelCase = 12						,      _UpperCAmelCase = 3072						,      _UpperCAmelCase = "gelu"						,      _UpperCAmelCase = 0.1						,      _UpperCAmelCase = 0.1						,      _UpperCAmelCase = 512						,      _UpperCAmelCase = 2						,      _UpperCAmelCase = 0.0_2						,      _UpperCAmelCase = 1e-1_2						,      _UpperCAmelCase = False						,      **_UpperCAmelCase						,      ):
									super().__init__(pad_token_id=_UpperCAmelCase						,      **_UpperCAmelCase  )

									__a			:    Union[str, Any]      							=	attention_window
									__a			:    List[Any]      							=	sep_token_id
									__a			:    Optional[Any]      							=	bos_token_id
									__a			:    List[str]      							=	eos_token_id
									__a			:    List[Any]      							=	vocab_size
									__a			:    Optional[Any]      							=	hidden_size
									__a			:    Union[str, Any]      							=	num_hidden_layers
									__a			:    Optional[int]      							=	num_attention_heads
									__a			:    Optional[Any]      							=	hidden_act
									__a			:    Dict      							=	intermediate_size
									__a			:    Dict      							=	hidden_dropout_prob
									__a			:    Optional[int]      							=	attention_probs_dropout_prob
									__a			:    Tuple      							=	max_position_embeddings
									__a			:    List[Any]      							=	type_vocab_size
									__a			:    int      							=	initializer_range
									__a			:    Optional[int]      							=	layer_norm_eps
									__a			:    str      							=	onnx_export






class 					__lowercase      (      _UpperCamelCase				):







					'''simple docstring'''




					def __init__(    self						,      _UpperCAmelCase						,      _UpperCAmelCase = "default"						,      _UpperCAmelCase = None  ):
									super().__init__(_UpperCAmelCase						,      _UpperCAmelCase						,      _UpperCAmelCase  )
									__a			:    List[Any]      							=	True







					@property
					def 			_lowerCamelCase		(    self  ):
									if self.task == "multiple-choice":
													__a			:    List[str]      							=	{0: '''batch''', 1: '''choice''', 2: '''sequence'''}
									else:
													__a			:    Tuple      							=	{0: '''batch''', 1: '''sequence'''}
									return OrderedDict(
									    [
									        ('''input_ids''', dynamic_axis),
									        ('''attention_mask''', dynamic_axis),
									        ('''global_attention_mask''', dynamic_axis),
									    ]  )







					@property
					def 			_lowerCamelCase		(    self  ):
									__a			:    str      							=	super().outputs
									if self.task == "default":
													__a			:    Optional[Any]      							=	{0: '''batch'''}
									return outputs







					@property
					def 			_lowerCamelCase		(    self  ):
									return 1e-4







					@property
					def 			_lowerCamelCase		(    self  ):
									# needs to be >= 14 to support tril operator
									return max(super().default_onnx_opset						,      14  )







					def 			_lowerCamelCase		(    self						,      _UpperCAmelCase						,      _UpperCAmelCase = -1						,      _UpperCAmelCase = -1						,      _UpperCAmelCase = False						,      _UpperCAmelCase = None						,      ):
									__a			:    Dict      							=	super().generate_dummy_inputs(
									    preprocessor=_UpperCAmelCase						,      batch_size=_UpperCAmelCase						,      seq_length=_UpperCAmelCase						,      is_pair=_UpperCAmelCase						,      framework=_UpperCAmelCase  )
									import torch

									# for some reason, replacing this code by inputs["global_attention_mask"] = torch.randint(2, inputs["input_ids"].shape, dtype=torch.int64)
									# makes the export fail randomly
									__a			:    str      							=	torch.zeros_like(inputs['''input_ids''']  )
									# make every second token global
									__a			:    int      							=	1

									return inputs





'''simple docstring'''







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


lowercase      :   Optional[int]      =       logging.get_logger(__name__)

lowercase      :   Optional[Any]      =       {
    """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 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     Any          =					"""pegasus"""
     lowerCAmelCase_  :     Dict          =					["""past_key_values"""]
     lowerCAmelCase_  :     str          =					{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}







     def __init__(				self							,__a=50_265							,__a=1_024							,__a=12							,__a=4_096							,__a=16							,__a=12							,__a=4_096							,__a=16							,__a=0.0							,__a=0.0							,__a=True							,__a=True							,__a="gelu"							,__a=1_024							,__a=0.1							,__a=0.0							,__a=0.0							,__a=0.02							,__a=0							,__a=False							,__a=0							,__a=1							,__a=1							,**__a							,)      ->				int:
          snake_case			:      List[Any]        =			vocab_size
          snake_case			:      Optional[Any]        =			max_position_embeddings
          snake_case			:      List[Any]        =			d_model
          snake_case			:      str        =			encoder_ffn_dim
          snake_case			:      List[Any]        =			encoder_layers
          snake_case			:      Optional[Any]        =			encoder_attention_heads
          snake_case			:      Union[str, Any]        =			decoder_ffn_dim
          snake_case			:      Tuple        =			decoder_layers
          snake_case			:      Union[str, Any]        =			decoder_attention_heads
          snake_case			:      Union[str, Any]        =			dropout
          snake_case			:      int        =			attention_dropout
          snake_case			:      int        =			activation_dropout
          snake_case			:      Optional[Any]        =			activation_function
          snake_case			:      Tuple        =			init_std
          snake_case			:      Union[str, Any]        =			encoder_layerdrop
          snake_case			:      int        =			decoder_layerdrop
          snake_case			:      Dict        =			use_cache
          snake_case			:      Dict        =			encoder_layers
          snake_case			:      List[Any]        =			scale_embedding  # scale factor will be sqrt(d_model) if True
          super().__init__(
              pad_token_id=__a							,eos_token_id=__a							,is_encoder_decoder=__a							,decoder_start_token_id=__a							,forced_eos_token_id=__a							,**__a							,)







     @property
     def 			snake_case_      (				self							)      ->				int:
          return self.encoder_attention_heads







     @property
     def 			snake_case_      (				self							)      ->				int:
          return self.d_model



