


import unittest

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







class  snake_case_     (unittest.TestCase   ):
					def 				lowerCamelCase__(   self     :Dict   )      ->					Any:
												a__    =  ['a', 'b', 'c']

												# Defaults to last layer if both are None
												a__   ,      a__    =  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
												a__   ,      a__    =  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
												a__   ,      a__    =  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
												a__   ,      a__    =  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 				lowerCamelCase__(   self     :Tuple   )      ->					Union[str, Any]:
												# 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 				lowerCamelCase__(   self     :List[Any]   )      ->					Optional[int]:
												a__    =  BackboneMixin()

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

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








from decimal import Decimal, getcontext
from math import ceil, factorial






def 							__lowercase     (				__lowerCAmelCase							:       int     ):

							if not isinstance(__lowerCAmelCase      ,					__lowerCAmelCase     ):
														raise TypeError('Undefined for non-integers'     )
							elif precision < 1:
														raise ValueError('Undefined for non-natural numbers'     )

							a__    =  precision
							a__    =  ceil(precision / 1_4     )
							a__    =  4_2_6_8_8_0 * Decimal(1_0_0_0_5     ).sqrt()
							a__    =  1
							a__    =  1_3_5_9_1_4_0_9
							a__    =  Decimal(__lowerCAmelCase     )
							for k in range(1      ,					__lowerCAmelCase     ):
														a__    =  factorial(6 * k     ) // (factorial(3 * k     ) * factorial(__lowerCAmelCase     ) ** 3)
														linear_term += 5_4_5_1_4_0_1_3_4
														exponential_term *= -2_6_2_5_3_7_4_1_2_6_4_0_7_6_8_0_0_0
														partial_sum += Decimal(multinomial_term * linear_term     ) / exponential_term
							return str(constant_term / partial_sum     )[:-1]


if __name__ == "__main__":
						snake_case							: Tuple      =   50
						print(f"""The first {n} digits of pi is: {pi(n)}""")




