






'''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							:						int			)							->    Optional[Any]:

									'''simple docstring'''







									UpperCamelCase__         = ["""a""", """b""", """c"""]

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

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

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

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






			def 				A      (   self							:						List[Any]			)							->    Optional[Any]:

									'''simple docstring'''







									with self.assertRaises(lowercase			):
															verify_out_features_out_indices(["""a""", """b"""] ,      (0, 1) ,      lowercase			)

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

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

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

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

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

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

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

									'''simple docstring'''







									UpperCamelCase__         = BackboneMixin()

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

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








'''simple docstring'''


import math







def 	__magic_name__( _A					):
						'''simple docstring'''





						assert isinstance(_A						,      _A					) and (
						    number >= 0
						), "'number' must been an int and positive"

						if 1 < number < 4:
												# 2 and 3 are primes
												return True
						elif number < 2 or not number % 2:
												# Negatives, 0, 1 and all even numbers are not primes
												return False

						UpperCamelCase__         = range(3						,      int(math.sqrt(_A					) + 1					)						,      2					)
						return not any(not number % i for i in odd_numbers					)







def 	__magic_name__( _A						,      _A=1						,      **_A					):
						'''simple docstring'''





						UpperCamelCase__         = factor * value
						UpperCamelCase__         = value

						while not is_prime(_A					):
												value += 1 if not ("desc" in kwargs and kwargs["desc"] is True) else -1

						if value == first_value_val:
												return next_prime(value + 1						,      **_A					)
						return value
