





'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


lowercase_         =			{
    """configuration_sam""": [
        """SAM_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """SamConfig""",
        """SamMaskDecoderConfig""",
        """SamPromptEncoderConfig""",
        """SamVisionConfig""",
    ],
    """processing_sam""": ["""SamProcessor"""],
}


try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_         =			[
          """SAM_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """SamModel""",
          """SamPreTrainedModel""",
      ]
try:
      if not is_tf_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_         =			[
          """TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """TFSamModel""",
          """TFSamPreTrainedModel""",
      ]
try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_         =			["""SamImageProcessor"""]


if TYPE_CHECKING:
      from .configuration_sam import (
          SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
          SamConfig,
          SamMaskDecoderConfig,
          SamPromptEncoderConfig,
          SamVisionConfig,
      )
      from .processing_sam import SamProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

      try:
            if not is_tf_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .image_processing_sam import SamImageProcessor

else:
      import sys

      lowercase_         =			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)










'''simple docstring'''

def lowerCamelCase						(					__lowerCamelCase			:   int   )						->int:
    barcode //= 10  # exclude the last digit
    _SCREAMING_SNAKE_CASE     =      False
    _SCREAMING_SNAKE_CASE     =      0

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

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





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





def lowerCamelCase						(					__lowerCamelCase			:   str   )						->int:
    if str(__lowerCamelCase   ).isalpha():
        _SCREAMING_SNAKE_CASE     =      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()
      lowercase_         =			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.""")



