



'''simple docstring'''



def 	__lowerCAmelCase       (				lowerCamelCase :    int       ):






	'''simple docstring'''




	barcode //= 10  # exclude the last digit
	__lowerCAmelCase       				=	False
	__lowerCAmelCase       				=	0

	# extract and check each digit
	while barcode != 0:
		__lowerCAmelCase       				=	1 if checker else 3
		s += mult * (barcode % 10)
		barcode //= 10
		__lowerCAmelCase       				=	not checker

	return (10 - (s % 10)) % 10



def 	__lowerCAmelCase       (				lowerCamelCase :    int       ):






	'''simple docstring'''




	return len(str(lowerCamelCase       )       ) == 13 and get_check_digit(lowerCamelCase       ) == barcode % 10



def 	__lowerCAmelCase       (				lowerCamelCase :    str       ):






	'''simple docstring'''




	if str(lowerCamelCase       ).isalpha():
		__lowerCAmelCase       				=	f'''Barcode \'{barcode}\' has alphabetic characters.'''
		raise ValueError(lowerCamelCase       )
	elif int(lowerCamelCase       ) < 0:
		raise ValueError("The entered barcode has a negative value. Try again."       )
	else:
		return int(lowerCamelCase       )


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	lowerCAmelCase						:		Dict						      = get_barcode(input('''Barcode: ''').strip())

	if is_valid(barcode):
		print(f'\'{barcode}\' is a valid barcode.')
	else:
		print(f'\'{barcode}\' is NOT a valid barcode.')




'''simple docstring'''



import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
	from PIL import Image






class        UpperCAmelCase__						(		unittest.TestCase				,							UpperCamelCase__			):



					def 							UpperCAmelCase_			(     self  )  ->      Optional[int]:
						__lowerCAmelCase       				=	load_tool("image-question-answering"  )
						self.tool.setup()
						__lowerCAmelCase       				=	load_tool("image-question-answering"      ,					remote=UpperCamelCase  )



					def 							UpperCAmelCase_			(     self  )  ->      Optional[int]:
						__lowerCAmelCase       				=	Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"  )  ) / "000000039769.png"  )
						__lowerCAmelCase       				=	self.tool(UpperCamelCase      ,					"How many cats are sleeping on the couch?"  )
						self.assertEqual(UpperCamelCase      ,					"2"  )



					def 							UpperCAmelCase_			(     self  )  ->      Dict:
						__lowerCAmelCase       				=	Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"  )  ) / "000000039769.png"  )
						__lowerCAmelCase       				=	self.remote_tool(UpperCamelCase      ,					"How many cats are sleeping on the couch?"  )
						self.assertEqual(UpperCamelCase      ,					"2"  )



					def 							UpperCAmelCase_			(     self  )  ->      Optional[Any]:
						__lowerCAmelCase       				=	Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"  )  ) / "000000039769.png"  )
						__lowerCAmelCase       				=	self.tool(image=UpperCamelCase      ,					question="How many cats are sleeping on the couch?"  )
						self.assertEqual(UpperCamelCase      ,					"2"  )



					def 							UpperCAmelCase_			(     self  )  ->      Dict:
						__lowerCAmelCase       				=	Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"  )  ) / "000000039769.png"  )
						__lowerCAmelCase       				=	self.remote_tool(image=UpperCamelCase      ,					question="How many cats are sleeping on the couch?"  )
						self.assertEqual(UpperCamelCase      ,					"2"  )