





'''simple docstring'''

from typing import TYPE_CHECKING

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


lowercase_         =			{
    """configuration_realm""": ["""REALM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RealmConfig"""],
    """tokenization_realm""": ["""RealmTokenizer"""],
}

try:
      if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_         =			["""RealmTokenizerFast"""]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_         =			[
          """REALM_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """RealmEmbedder""",
          """RealmForOpenQA""",
          """RealmKnowledgeAugEncoder""",
          """RealmPreTrainedModel""",
          """RealmReader""",
          """RealmScorer""",
          """load_tf_weights_in_realm""",
      ]
      lowercase_         =			["""RealmRetriever"""]


if TYPE_CHECKING:
      from .configuration_realm import REALM_PRETRAINED_CONFIG_ARCHIVE_MAP, RealmConfig
      from .tokenization_realm import RealmTokenizer

      try:
            if not is_tokenizers_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_realm import RealmTokenizerFast

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_realm import (
                REALM_PRETRAINED_MODEL_ARCHIVE_LIST,
                RealmEmbedder,
                RealmForOpenQA,
                RealmKnowledgeAugEncoder,
                RealmPreTrainedModel,
                RealmReader,
                RealmScorer,
                load_tf_weights_in_realm,
            )
            from .retrieval_realm import RealmRetriever


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.""")



