

def 			__UpperCamelCase    (lowerCAmelCase					:  int     )     ->  int:
      barcode //= 10  # exclude the last digit
      A    =				False
      A    =				0

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

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


def 			__UpperCamelCase    (lowerCAmelCase					:  int     )     ->  bool:
      return len(str(lowerCAmelCase     )     ) == 13 and get_check_digit(lowerCAmelCase     ) == barcode % 10


def 			__UpperCamelCase    (lowerCAmelCase					:  str     )     ->  int:
      if str(lowerCAmelCase     ).isalpha():
            A    =				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()
  _UpperCAmelCase    	=			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.''')






import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import EfficientNetImageProcessor



class        _UpperCAmelCase (   unittest.TestCase			):
  '''simple docstring'''







  def __init__( self	: Optional[Any]		,						UpperCamelCase__	: List[Any]		,						UpperCamelCase__	: Dict=13		,						UpperCamelCase__	: Dict=3		,						UpperCamelCase__	: Tuple=18		,						UpperCamelCase__	: Optional[int]=30		,						UpperCamelCase__	: List[str]=400		,						UpperCamelCase__	: Tuple=True		,						UpperCamelCase__	: List[str]=None		,						UpperCamelCase__	: Optional[int]=True		,						UpperCamelCase__	: int=[0.5, 0.5, 0.5]		,						UpperCamelCase__	: Any=[0.5, 0.5, 0.5]		,						):
        A    =				size if size is not None else {'height': 18, 'width': 18}
        A    =				parent
        A    =				batch_size
        A    =				num_channels
        A    =				image_size
        A    =				min_resolution
        A    =				max_resolution
        A    =				do_resize
        A    =				size
        A    =				do_normalize
        A    =				image_mean
        A    =				image_std







  def 	UpperCamelCase       ( self	: str ):
        return {
            "image_mean": self.image_mean,
            "image_std": self.image_std,
            "do_normalize": self.do_normalize,
            "do_resize": self.do_resize,
            "size": self.size,
        }



@require_torch
@require_vision
class        _UpperCAmelCase (   __lowercase     ,				unittest.TestCase			):
  '''simple docstring'''







  SCREAMING_SNAKE_CASE							:				Dict					      =				EfficientNetImageProcessor if is_vision_available() else None







  def 	UpperCamelCase       ( self	: Tuple ):
        A    =				EfficientNetImageProcessorTester(self )







  @property
  def 	UpperCamelCase       ( self	: Optional[int] ):
        return self.image_processor_tester.prepare_image_processor_dict()







  def 	UpperCamelCase       ( self	: List[str] ):
        A    =				self.image_processing_class(**self.image_processor_dict )
        self.assertTrue(hasattr(UpperCamelCase__		,						'image_mean' ) )
        self.assertTrue(hasattr(UpperCamelCase__		,						'image_std' ) )
        self.assertTrue(hasattr(UpperCamelCase__		,						'do_normalize' ) )
        self.assertTrue(hasattr(UpperCamelCase__		,						'do_resize' ) )
        self.assertTrue(hasattr(UpperCamelCase__		,						'size' ) )







  def 	UpperCamelCase       ( self	: Union[str, Any] ):
        A    =				self.image_processing_class.from_dict(self.image_processor_dict )
        self.assertEqual(image_processor.size		,						{'height': 18, 'width': 18} )

        A    =				self.image_processing_class.from_dict(self.image_processor_dict		,						size=42 )
        self.assertEqual(image_processor.size		,						{'height': 42, 'width': 42} )







  def 	UpperCamelCase       ( self	: Optional[int] ):
        # Initialize image_processing
        A    =				self.image_processing_class(**self.image_processor_dict )
        # create random PIL images
        A    =				prepare_image_inputs(self.image_processor_tester		,						equal_resolution=UpperCamelCase__ )
        for image in image_inputs:
              self.assertIsInstance(UpperCamelCase__		,						Image.Image )

        # Test not batched input
        A    =				image_processing(image_inputs[0]		,						return_tensors='pt' ).pixel_values
        self.assertEqual(
            encoded_images.shape		,						(
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size['height'],
                self.image_processor_tester.size['width'],
            )		,						)

        # Test batched
        A    =				image_processing(UpperCamelCase__		,						return_tensors='pt' ).pixel_values
        self.assertEqual(
            encoded_images.shape		,						(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size['height'],
                self.image_processor_tester.size['width'],
            )		,						)







  def 	UpperCamelCase       ( self	: Optional[int] ):
        # Initialize image_processing
        A    =				self.image_processing_class(**self.image_processor_dict )
        # create random numpy tensors
        A    =				prepare_image_inputs(self.image_processor_tester		,						equal_resolution=UpperCamelCase__		,						numpify=UpperCamelCase__ )
        for image in image_inputs:
              self.assertIsInstance(UpperCamelCase__		,						np.ndarray )

        # Test not batched input
        A    =				image_processing(image_inputs[0]		,						return_tensors='pt' ).pixel_values
        self.assertEqual(
            encoded_images.shape		,						(
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size['height'],
                self.image_processor_tester.size['width'],
            )		,						)

        # Test batched
        A    =				image_processing(UpperCamelCase__		,						return_tensors='pt' ).pixel_values
        self.assertEqual(
            encoded_images.shape		,						(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size['height'],
                self.image_processor_tester.size['width'],
            )		,						)







  def 	UpperCamelCase       ( self	: Optional[Any] ):
        # Initialize image_processing
        A    =				self.image_processing_class(**self.image_processor_dict )
        # create random PyTorch tensors
        A    =				prepare_image_inputs(self.image_processor_tester		,						equal_resolution=UpperCamelCase__		,						torchify=UpperCamelCase__ )
        for image in image_inputs:
              self.assertIsInstance(UpperCamelCase__		,						torch.Tensor )

        # Test not batched input
        A    =				image_processing(image_inputs[0]		,						return_tensors='pt' ).pixel_values
        self.assertEqual(
            encoded_images.shape		,						(
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size['height'],
                self.image_processor_tester.size['width'],
            )		,						)

        # Test batched
        A    =				image_processing(UpperCamelCase__		,						return_tensors='pt' ).pixel_values
        self.assertEqual(
            encoded_images.shape		,						(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size['height'],
                self.image_processor_tester.size['width'],
            )		,						)



