



'''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   A			(		self    :  str	)    ->	str:
								UpperCAmelCase				: Dict											=	['''a''', '''b''', '''c''']

								# Defaults to last layer if both are None
								UpperCAmelCase				: 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				: List[Any]											=	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				: Optional[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				: Tuple											=	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   A			(		self    :  List[str]	)    ->	int:
								# Stage names must be set
								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   A			(		self    :  List[str]	)    ->	List[Any]:
								UpperCAmelCase				: Optional[Any]											=	BackboneMixin()

								UpperCAmelCase				: Optional[int]											=	['''a''', '''b''', '''c''']
								UpperCAmelCase				: Optional[Any]											=	['''a''', '''c''']
								UpperCAmelCase				: Optional[int]											=	[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				: Tuple											=	['''a''', '''b''']
								self.assertEqual(backbone.out_features	,    ['''a''', '''b''']	)
								self.assertEqual(backbone.out_indices	,    [0, 1]	)

								UpperCAmelCase				: List[Any]											=	[-3, -1]
								self.assertEqual(backbone.out_features	,    ['''a''', '''c''']	)
								self.assertEqual(backbone.out_indices	,    [-3, -1]	)










'''simple docstring'''






import numpy as np

UpperCamelCase__:     Any										=    [
    ["a", "b", "c", "d", "e"],
    ["f", "g", "h", "i", "k"],
    ["l", "m", "n", "o", "p"],
    ["q", "r", "s", "t", "u"],
    ["v", "w", "x", "y", "z"],
]

class        SCREAMING_SNAKE_CASE:







	"""simple docstring"""






	def __init__(		self    :  Any	)    ->	None:
								UpperCAmelCase				: Optional[int]											=	np.array(__snake_case	)







	def   A			(		self    :  str	,    __snake_case    :  str	)    ->	np.ndarray:
								UpperCAmelCase							,	UpperCAmelCase				: Dict											=	np.where(letter == self.SQUARE	)
								UpperCAmelCase				: Dict											=	np.concatenate([indexa + 1, indexa + 1]	)
								return indexes







	def   A			(		self    :  Union[str, Any]	,    __snake_case    :  int	,    __snake_case    :  int	)    ->	str:
								UpperCAmelCase				: int											=	self.SQUARE[indexa - 1, indexa - 1]
								return letter







	def   A			(		self    :  List[Any]	,    __snake_case    :  str	)    ->	str:
								UpperCAmelCase				: Any											=	message.lower()
								UpperCAmelCase				: List[Any]											=	message.replace(''' '''	,    ''''''	)
								UpperCAmelCase				: List[Any]											=	message.replace('''j'''	,    '''i'''	)

								UpperCAmelCase				: Tuple											=	np.empty((2, len(__snake_case	))	)
								for letter_index in range(len(__snake_case	)	):
															UpperCAmelCase				: str											=	self.letter_to_numbers(message[letter_index]	)

															UpperCAmelCase				: Any											=	numbers[0]
															UpperCAmelCase				: Optional[Any]											=	numbers[1]

								UpperCAmelCase				: List[str]											=	first_step.reshape(2 * len(__snake_case	)	)
								UpperCAmelCase				: Union[str, Any]											=	''''''
								for numbers_index in range(len(__snake_case	)	):
															UpperCAmelCase				: Dict											=	int(second_step[numbers_index * 2]	)
															UpperCAmelCase				: Union[str, Any]											=	int(second_step[(numbers_index * 2) + 1]	)
															UpperCAmelCase				: Dict											=	self.numbers_to_letter(__snake_case	,    __snake_case	)
															UpperCAmelCase				: int											=	encoded_message + letter

								return encoded_message







	def   A			(		self    :  Optional[Any]	,    __snake_case    :  str	)    ->	str:
								UpperCAmelCase				: str											=	message.lower()
								message.replace(''' '''	,    ''''''	)
								UpperCAmelCase				: Optional[int]											=	np.empty(2 * len(__snake_case	)	)
								for letter_index in range(len(__snake_case	)	):
															UpperCAmelCase				: int											=	self.letter_to_numbers(message[letter_index]	)
															UpperCAmelCase				: Optional[Any]											=	numbers[0]
															UpperCAmelCase				: List[Any]											=	numbers[1]

								UpperCAmelCase				: Tuple											=	first_step.reshape((2, len(__snake_case	))	)
								UpperCAmelCase				: str											=	''''''
								for numbers_index in range(len(__snake_case	)	):
															UpperCAmelCase				: Tuple											=	int(second_step[0, numbers_index]	)
															UpperCAmelCase				: List[str]											=	int(second_step[1, numbers_index]	)
															UpperCAmelCase				: Union[str, Any]											=	self.numbers_to_letter(__snake_case	,    __snake_case	)
															UpperCAmelCase				: Union[str, Any]											=	decoded_message + letter

								return decoded_message





