import unittest

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






class      __lowercase					(    unittest.TestCase    ):

						def        __a		(	self				:      List[str]   )							->		Dict:


									'''simple docstring'''

									lowercase							=		['''a''', '''b''', '''c''']

									# Defaults to last layer if both are None
									lowercase		,lowercase							=		get_aligned_output_features_output_indices(__lowerCamelCase							,							__lowerCamelCase							,							__lowerCamelCase   )
									self.assertEqual(__lowerCamelCase							,							['''c''']   )
									self.assertEqual(__lowerCamelCase							,							[2]   )

									# Out indices set to match out features
									lowercase		,lowercase							=		get_aligned_output_features_output_indices(['''a''', '''c''']							,							__lowerCamelCase							,							__lowerCamelCase   )
									self.assertEqual(__lowerCamelCase							,							['''a''', '''c''']   )
									self.assertEqual(__lowerCamelCase							,							[0, 2]   )

									# Out features set to match out indices
									lowercase		,lowercase							=		get_aligned_output_features_output_indices(__lowerCamelCase							,							[0, 2]							,							__lowerCamelCase   )
									self.assertEqual(__lowerCamelCase							,							['''a''', '''c''']   )
									self.assertEqual(__lowerCamelCase							,							[0, 2]   )

									# Out features selected from negative indices
									lowercase		,lowercase							=		get_aligned_output_features_output_indices(__lowerCamelCase							,							[-3, -1]							,							__lowerCamelCase   )
									self.assertEqual(__lowerCamelCase							,							['''a''', '''c''']   )
									self.assertEqual(__lowerCamelCase							,							[-3, -1]   )

						def        __a		(	self				:      Optional[Any]   )							->		Optional[int]:


									'''simple docstring'''

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

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

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

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

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

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

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

									# Out features and out indices should be in order
									with self.assertRaises(__lowerCamelCase   ):
												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        __a		(	self				:      str   )							->		Optional[Any]:


									'''simple docstring'''

									lowercase							=		BackboneMixin()

									lowercase							=		['''a''', '''b''', '''c''']
									lowercase							=		['''a''', '''c''']
									lowercase							=		[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
									lowercase							=		['''a''', '''b''']
									self.assertEqual(backbone.out_features							,							['''a''', '''b''']   )
									self.assertEqual(backbone.out_indices							,							[0, 1]   )

									lowercase							=		[-3, -1]
									self.assertEqual(backbone.out_features							,							['''a''', '''c''']   )
									self.assertEqual(backbone.out_indices							,							[-3, -1]   )






import logging

from transformers import PretrainedConfig


A_      =      logging.getLogger(__name__)


A_      =      {
    "bertabs-finetuned-cnndm": "https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json",
}






class      __lowercase					(    _A    ):
						lowercase					 =     'bertabs'

						def __init__(	self				:      Dict							,							__lowerCamelCase				:      Tuple=3_05_22							,							__lowerCamelCase				:      Tuple=5_12							,							__lowerCamelCase				:      List[Any]=6							,							__lowerCamelCase				:      Any=5_12							,							__lowerCamelCase				:      Any=8							,							__lowerCamelCase				:      Union[str, Any]=5_12							,							__lowerCamelCase				:      Tuple=0.2							,							__lowerCamelCase				:      str=6							,							__lowerCamelCase				:      int=7_68							,							__lowerCamelCase				:      int=8							,							__lowerCamelCase				:      List[Any]=20_48							,							__lowerCamelCase				:      Union[str, Any]=0.2							,							**__lowerCamelCase				:      Dict							,							)							->		Dict:


									'''simple docstring'''

									super().__init__(**__lowerCamelCase   )

									lowercase							=		vocab_size
									lowercase							=		max_pos

									lowercase							=		enc_layers
									lowercase							=		enc_hidden_size
									lowercase							=		enc_heads
									lowercase							=		enc_ff_size
									lowercase							=		enc_dropout

									lowercase							=		dec_layers
									lowercase							=		dec_hidden_size
									lowercase							=		dec_heads
									lowercase							=		dec_ff_size
									lowercase							=		dec_dropout





