

'''simple docstring'''





from typing import TYPE_CHECKING

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


_UpperCAmelCase    	=			{
    "configuration_rwkv": ["RWKV_PRETRAINED_CONFIG_ARCHIVE_MAP", "RwkvConfig", "RwkvOnnxConfig"],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _UpperCAmelCase    	=			[
      "RWKV_PRETRAINED_MODEL_ARCHIVE_LIST",
      "RwkvForCausalLM",
      "RwkvModel",
      "RwkvPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_rwkv import RWKV_PRETRAINED_CONFIG_ARCHIVE_MAP, RwkvConfig, RwkvOnnxConfig

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_rwkv import (
        RWKV_PRETRAINED_MODEL_ARCHIVE_LIST,
        RwkvForCausalLM,
        RwkvModel,
        RwkvPreTrainedModel,
    )
else:
  import sys

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






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



