
def        a_		(       __lowercase   :	str ) ->  bool:
			return credit_card_number.startswith(('34', '35', '37', '4', '5', '6') )






def        a_		(       __lowercase   :	str ) ->  bool:
			_snake_case		=			credit_card_number
			_snake_case		=			0
			_snake_case		=			len(__lowercase ) - 2
			for i in range(__lowercase       ,					-1       ,					-2 ):
						#  double the value of every second digit
						_snake_case		=			int(cc_number[i] )
						digit *= 2
						# If doubling of a number results in a two digit number
						# i.e greater than 9(e.g., 6 × 2 = 12),
						# then add the digits of the product (e.g., 12: 1 + 2 = 3, 15: 1 + 5 = 6),
						# to get a single digit number.
						if digit > 9:
									digit %= 10
									digit += 1
						_snake_case		=			cc_number[:i] + str(__lowercase ) + cc_number[i + 1 :]
						total += digit

			# Sum up the remaining digits
			for i in range(len(__lowercase ) - 1       ,					-1       ,					-2 ):
						total += int(cc_number[i] )

			return total % 10 == 0






def        a_		(       __lowercase   :	str ) ->  bool:
			_snake_case		=			f'''{credit_card_number} is an invalid credit card number because'''
			if not credit_card_number.isdigit():
						print(f'''{error_message} it has nonnumerical characters.''' )
						return False

			if not 13 <= len(__lowercase ) <= 16:
						print(f'''{error_message} of its length.''' )
						return False

			if not validate_initial_digits(__lowercase ):
						print(f'''{error_message} of its first two digits.''' )
						return False

			if not luhn_validation(__lowercase ):
						print(f'''{error_message} it fails the Luhn check.''' )
						return False

			print(f'''{credit_card_number} is a valid credit card number.''' )
			return True


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			validate_credit_card_number('''4111111111111111''')
			validate_credit_card_number('''32323''')

import os
import tempfile
import unittest
from pathlib import Path

from transformers import AutoConfig, is_torch_available
from transformers.testing_utils import require_torch, torch_device


if is_torch_available():
			from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments




@require_torch
class    SCREAMING_SNAKE_CASE__     (	unittest.TestCase					):





	'''simple docstring'''



	def  A							(  self	:    List[Any]			,  lowercase	:    Dict	):


				'''simple docstring'''


				for model_result in results.values():
							for batch_size, sequence_length in zip(model_result['bs']			,  model_result['ss']	):
										_snake_case		=			model_result['result'][batch_size][sequence_length]
										self.assertIsNotNone(lowercase	)



	def  A							(  self	:    str	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_inference_result	)
				self.check_results_dict_not_empty(results.memory_inference_result	)



	def  A							(  self	:    Any	):


				'''simple docstring'''


				_snake_case		=			'sgugger/tiny-distilbert-classification'
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  only_pretrain_model=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_inference_result	)
				self.check_results_dict_not_empty(results.memory_inference_result	)



	def  A							(  self	:    Optional[int]	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  torchscript=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_inference_result	)
				self.check_results_dict_not_empty(results.memory_inference_result	)



	@unittest.skipIf(torch_device == 'cpu'			,  'Cant do half precision'	)
	def  A							(  self	:    Optional[Any]	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  fpaa=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_inference_result	)
				self.check_results_dict_not_empty(results.memory_inference_result	)



	def  A							(  self	:    str	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				_snake_case		=			AutoConfig.from_pretrained(lowercase	)
				# set architectures equal to `None`
				_snake_case		=			None
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase			,  configs=[config]	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_inference_result	)
				self.check_results_dict_not_empty(results.memory_inference_result	)



	def  A							(  self	:    Optional[Any]	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_train_result	)
				self.check_results_dict_not_empty(results.memory_train_result	)



	@unittest.skipIf(torch_device == 'cpu'			,  'Can\'t do half precision'	)
	def  A							(  self	:    str	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  fpaa=lowercase			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_train_result	)
				self.check_results_dict_not_empty(results.memory_train_result	)



	def  A							(  self	:    Tuple	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				_snake_case		=			AutoConfig.from_pretrained(lowercase	)
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase			,  configs=[config]	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_inference_result	)
				self.check_results_dict_not_empty(results.memory_inference_result	)



	def  A							(  self	:    Union[str, Any]	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tinier_bart'
				_snake_case		=			AutoConfig.from_pretrained(lowercase	)
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase			,  configs=[config]	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_inference_result	)
				self.check_results_dict_not_empty(results.memory_inference_result	)



	def  A							(  self	:    Dict	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				_snake_case		=			AutoConfig.from_pretrained(lowercase	)
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase			,  configs=[config]	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_train_result	)
				self.check_results_dict_not_empty(results.memory_train_result	)



	def  A							(  self	:    Dict	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tinier_bart'
				_snake_case		=			AutoConfig.from_pretrained(lowercase	)
				_snake_case		=			PyTorchBenchmarkArguments(
				    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  multi_process=lowercase			,  )
				_snake_case		=			PyTorchBenchmark(lowercase			,  configs=[config]	)
				_snake_case		=			benchmark.run()
				self.check_results_dict_not_empty(results.time_train_result	)
				self.check_results_dict_not_empty(results.memory_train_result	)



	def  A							(  self	:    Optional[Any]	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'
				with tempfile.TemporaryDirectory() as tmp_dir:
							_snake_case		=			PyTorchBenchmarkArguments(
							    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  save_to_csv=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  inference_time_csv_file=os.path.join(lowercase			,  'inf_time.csv'	)			,  train_memory_csv_file=os.path.join(lowercase			,  'train_mem.csv'	)			,  inference_memory_csv_file=os.path.join(lowercase			,  'inf_mem.csv'	)			,  train_time_csv_file=os.path.join(lowercase			,  'train_time.csv'	)			,  env_info_csv_file=os.path.join(lowercase			,  'env.csv'	)			,  multi_process=lowercase			,  )
							_snake_case		=			PyTorchBenchmark(lowercase	)
							benchmark.run()
							self.assertTrue(Path(os.path.join(lowercase			,  'inf_time.csv'	)	).exists()	)
							self.assertTrue(Path(os.path.join(lowercase			,  'train_time.csv'	)	).exists()	)
							self.assertTrue(Path(os.path.join(lowercase			,  'inf_mem.csv'	)	).exists()	)
							self.assertTrue(Path(os.path.join(lowercase			,  'train_mem.csv'	)	).exists()	)
							self.assertTrue(Path(os.path.join(lowercase			,  'env.csv'	)	).exists()	)





	def  A							(  self	:    Union[str, Any]	):


				'''simple docstring'''


				_snake_case		=			'sshleifer/tiny-gpt2'

				def _check_summary_is_not_empty(lowercase	:    Optional[Any]	):
							self.assertTrue(hasattr(lowercase			,  'sequential'	)	)
							self.assertTrue(hasattr(lowercase			,  'cumulative'	)	)
							self.assertTrue(hasattr(lowercase			,  'current'	)	)
							self.assertTrue(hasattr(lowercase			,  'total'	)	)

				with tempfile.TemporaryDirectory() as tmp_dir:
							_snake_case		=			PyTorchBenchmarkArguments(
							    models=[MODEL_ID]			,  training=lowercase			,  inference=lowercase			,  sequence_lengths=[8]			,  batch_sizes=[1]			,  log_filename=os.path.join(lowercase			,  'log.txt'	)			,  log_print=lowercase			,  trace_memory_line_by_line=lowercase			,  multi_process=lowercase			,  )
							_snake_case		=			PyTorchBenchmark(lowercase	)
							_snake_case		=			benchmark.run()
							_check_summary_is_not_empty(result.inference_summary	)
							_check_summary_is_not_empty(result.train_summary	)
							self.assertTrue(Path(os.path.join(lowercase			,  'log.txt'	)	).exists()	)