'''simple docstring'''


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


snake_case__					:      Any				      =  logging.get_logger(__name__)

snake_case__					:      Tuple				      =  {
    "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 					__SCREAMING_SNAKE_CASE						(	lowerCamelCase_	):







		'''simple docstring'''






		lowerCamelCase_		:str						   =		'''pegasus'''
		lowerCamelCase_		:Dict						   =		['''past_key_values''']
		lowerCamelCase_		:str						   =		{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}


		def __init__(			self				,		snake_case_=5_0_2_6_5				,		snake_case_=1_0_2_4				,		snake_case_=1_2				,		snake_case_=4_0_9_6				,		snake_case_=1_6				,		snake_case_=1_2				,		snake_case_=4_0_9_6				,		snake_case_=1_6				,		snake_case_=0.0				,		snake_case_=0.0				,		snake_case_=True				,		snake_case_=True				,		snake_case_="gelu"				,		snake_case_=1_0_2_4				,		snake_case_=0.1				,		snake_case_=0.0				,		snake_case_=0.0				,		snake_case_=0.02				,		snake_case_=0				,		snake_case_=False				,		snake_case_=0				,		snake_case_=1				,		snake_case_=1				,		**snake_case_				,		):




							'''simple docstring'''

							UpperCAmelCase_							:       Optional[int]       =				vocab_size
							UpperCAmelCase_							:       Union[str, Any]       =				max_position_embeddings
							UpperCAmelCase_							:       Tuple       =				d_model
							UpperCAmelCase_							:       List[str]       =				encoder_ffn_dim
							UpperCAmelCase_							:       Union[str, Any]       =				encoder_layers
							UpperCAmelCase_							:       Optional[int]       =				encoder_attention_heads
							UpperCAmelCase_							:       Tuple       =				decoder_ffn_dim
							UpperCAmelCase_							:       Dict       =				decoder_layers
							UpperCAmelCase_							:       Dict       =				decoder_attention_heads
							UpperCAmelCase_							:       Any       =				dropout
							UpperCAmelCase_							:       List[str]       =				attention_dropout
							UpperCAmelCase_							:       List[str]       =				activation_dropout
							UpperCAmelCase_							:       int       =				activation_function
							UpperCAmelCase_							:       Optional[Any]       =				init_std
							UpperCAmelCase_							:       str       =				encoder_layerdrop
							UpperCAmelCase_							:       Union[str, Any]       =				decoder_layerdrop
							UpperCAmelCase_							:       Dict       =				use_cache
							UpperCAmelCase_							:       Tuple       =				encoder_layers
							UpperCAmelCase_							:       Tuple       =				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 _UpperCamelCase					(			self						):




							'''simple docstring'''

							return self.encoder_attention_heads






		@property
		def _UpperCamelCase					(			self						):




							'''simple docstring'''

							return self.d_model







'''simple docstring'''


import unittest

from transformers.utils.backbone_utils import (
    BackboneMixin,
    get_aligned_output_features_output_indices,
    verify_out_features_out_indices,
)






class 					__SCREAMING_SNAKE_CASE						(	unittest.TestCase	):







  '''simple docstring'''






  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       int       =				['a', 'b', 'c']

       # Defaults to last layer if both are None
       UpperCAmelCase_       ,      UpperCAmelCase_							:       List[str]       =				get_aligned_output_features_output_indices(snake_case_				,		snake_case_				,		snake_case_						)
       self.assertEqual(snake_case_				,		['c']						)
       self.assertEqual(snake_case_				,		[2]						)

       # Out indices set to match out features
       UpperCAmelCase_       ,      UpperCAmelCase_							:       int       =				get_aligned_output_features_output_indices(['a', 'c']				,		snake_case_				,		snake_case_						)
       self.assertEqual(snake_case_				,		['a', 'c']						)
       self.assertEqual(snake_case_				,		[0, 2]						)

       # Out features set to match out indices
       UpperCAmelCase_       ,      UpperCAmelCase_							:       List[Any]       =				get_aligned_output_features_output_indices(snake_case_				,		[0, 2]				,		snake_case_						)
       self.assertEqual(snake_case_				,		['a', 'c']						)
       self.assertEqual(snake_case_				,		[0, 2]						)

       # Out features selected from negative indices
       UpperCAmelCase_       ,      UpperCAmelCase_							:       int       =				get_aligned_output_features_output_indices(snake_case_				,		[-3, -1]				,		snake_case_						)
       self.assertEqual(snake_case_				,		['a', 'c']						)
       self.assertEqual(snake_case_				,		[-3, -1]						)


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       with self.assertRaises(snake_case_						):
            verify_out_features_out_indices(['a', 'b']				,		(0, 1)				,		snake_case_						)

       # Out features must be a list
       with self.assertRaises(snake_case_						):
            verify_out_features_out_indices(('a', 'b')				,		(0, 1)				,		['a', 'b']						)

       # Out features must be a subset of stage names
       with self.assertRaises(snake_case_						):
            verify_out_features_out_indices(['a', 'b']				,		(0, 1)				,		['a']						)

       # Out indices must be a list or tuple
       with self.assertRaises(snake_case_						):
            verify_out_features_out_indices(snake_case_				,		0				,		['a', 'b']						)

       # Out indices must be a subset of stage names
       with self.assertRaises(snake_case_						):
            verify_out_features_out_indices(snake_case_				,		(0, 1)				,		['a']						)

       # Out features and out indices must be the same length
       with self.assertRaises(snake_case_						):
            verify_out_features_out_indices(['a', 'b']				,		(0,)				,		['a', 'b', 'c']						)

       # Out features should match out indices
       with self.assertRaises(snake_case_						):
            verify_out_features_out_indices(['a', 'b']				,		(0, 2)				,		['a', 'b', 'c']						)

       # Out features and out indices should be in order
       with self.assertRaises(snake_case_						):
            verify_out_features_out_indices(['b', 'a']				,		(0, 1)				,		['a', 'b']						)

       # Check passes with valid inputs
       verify_out_features_out_indices(['a', 'b', 'd']				,		(0, 1, -1)				,		['a', 'b', 'c', 'd']						)






  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       List[str]       =				BackboneMixin()

       UpperCAmelCase_							:       Any       =				['a', 'b', 'c']
       UpperCAmelCase_							:       str       =				['a', 'c']
       UpperCAmelCase_							:       str       =				[0, 2]

       # Check that the output features and indices are set correctly
       self.assertEqual(backbone.out_features				,		['a', 'c']						)
       self.assertEqual(backbone.out_indices				,		[0, 2]						)

       # Check out features and indices are updated correctly
       UpperCAmelCase_							:       str       =				['a', 'b']
       self.assertEqual(backbone.out_features				,		['a', 'b']						)
       self.assertEqual(backbone.out_indices				,		[0, 1]						)

       UpperCAmelCase_							:       Optional[int]       =				[-3, -1]
       self.assertEqual(backbone.out_features				,		['a', 'c']						)
       self.assertEqual(backbone.out_indices				,		[-3, -1]						)






