





def 						_lowercase       (     __lowerCamelCase			:					List[Any]			)  ->   int:





     '''simple docstring'''





     barcode //= 10  # exclude the last digit
     UpperCamelCase__							:  List[str]								=     False
     UpperCamelCase__							:  Dict								=     0

     # extract and check each digit
     while barcode != 0:
          UpperCamelCase__							:  Union[str, Any]								=     1 if checker else 3
          s += mult * (barcode % 10)
          barcode //= 10
          UpperCamelCase__							:  Union[str, Any]								=     not checker

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







def 						_lowercase       (     __lowerCamelCase			:					int			)  ->   bool:





     '''simple docstring'''





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







def 						_lowercase       (     __lowerCamelCase			:					str			)  ->   int:





     '''simple docstring'''





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


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   _SCREAMING_SNAKE_CASE :					List[Any]			=	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.')








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_SCREAMING_SNAKE_CASE :					str			=	{
    """configuration_donut_swin""": ["""DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DonutSwinConfig"""],
    """processing_donut""": ["""DonutProcessor"""],
}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _SCREAMING_SNAKE_CASE :					List[Any]			=	[
       """DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """DonutSwinModel""",
       """DonutSwinPreTrainedModel""",
   ]

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _SCREAMING_SNAKE_CASE :					List[Any]			=	["""DonutFeatureExtractor"""]
   _SCREAMING_SNAKE_CASE :					Tuple			=	["""DonutImageProcessor"""]


if TYPE_CHECKING:
   from .configuration_donut_swin import DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP, DonutSwinConfig
   from .processing_donut import DonutProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_donut_swin import (
          DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
          DonutSwinModel,
          DonutSwinPreTrainedModel,
      )

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .feature_extraction_donut import DonutFeatureExtractor
      from .image_processing_donut import DonutImageProcessor

else:
   import sys

   _SCREAMING_SNAKE_CASE :					Optional[Any]			=	_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




