


def      lowerCAmelCase	(						lowerCAmelCase_	)->	int:
				barcode //= 10  # exclude the last digit
				lowerCAmelCase_	: List[str]      			=			False
				lowerCAmelCase_	: List[str]      			=			0

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

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



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



def      lowerCAmelCase	(						lowerCAmelCase_	)->	int:
				if str(lowerCAmelCase_	).isalpha():
								lowerCAmelCase_	: int      			=			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     :					Optional[int]       =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 List, Optional, Tuple, Union

from . import logging
from .import_utils import is_torch_available, is_torch_version


if is_torch_available():
						import torch

_UpperCAmelCase     :					List[Any]       =logging.get_logger(__name__)  # pylint: disable=invalid-name

try:
						from torch._dynamo import allow_in_graph as maybe_allow_in_graph
except (ImportError, ModuleNotFoundError):



						def      lowerCAmelCase	(						cls	)->	int:
										return cls



def      lowerCAmelCase	(						lowerCAmelCase_	,				lowerCAmelCase_ = None	,				lowerCAmelCase_ = None	,				lowerCAmelCase_ = None	,				lowerCAmelCase_ = None	,				)->	int:
				lowerCAmelCase_	: Tuple      			=			device
				lowerCAmelCase_	: List[str]      			=			shape[0]

				lowerCAmelCase_	: Union[str, Any]      			=			layout or torch.strided
				lowerCAmelCase_	: Union[str, Any]      			=			device or torch.device('''cpu'''	)

				if generator is not None:
								lowerCAmelCase_	: List[str]      			=			generator.device.type if not isinstance(lowerCAmelCase_	,				lowerCAmelCase_	) else generator[0].device.type
								if gen_device_type != device.type and gen_device_type == "cpu":
												lowerCAmelCase_	: Optional[Any]      			=			'''cpu'''
												if device != "mps":
																logger.info(
																    f"""The passed generator was created on 'cpu' even though a tensor on {device} was expected."""
																    f""" Tensors will be created on 'cpu' and then moved to {device}. Note that one can probably"""
																    f""" slighly speed up this function by passing a generator that was created on the {device} device."""	)
								elif gen_device_type != device.type and gen_device_type == "cuda":
												raise ValueError(f"""Cannot generate a {device} tensor from a generator of type {gen_device_type}."""	)

				if isinstance(lowerCAmelCase_	,				lowerCAmelCase_	):
								lowerCAmelCase_	: Dict      			=			(1,) + shape[1:]
								lowerCAmelCase_	: Union[str, Any]      			=			[
								    torch.randn(lowerCAmelCase_	,				generator=generator[i]	,				device=lowerCAmelCase_	,				dtype=lowerCAmelCase_	,				layout=lowerCAmelCase_	)
								    for i in range(lowerCAmelCase_	)
								]
								lowerCAmelCase_	: Tuple      			=			torch.cat(lowerCAmelCase_	,				dim=0	).to(lowerCAmelCase_	)
				else:
								lowerCAmelCase_	: int      			=			torch.randn(lowerCAmelCase_	,				generator=lowerCAmelCase_	,				device=lowerCAmelCase_	,				dtype=lowerCAmelCase_	,				layout=lowerCAmelCase_	).to(lowerCAmelCase_	)

				return latents




def      lowerCAmelCase	(						lowerCAmelCase_	)->	Optional[Any]:
				if is_torch_version('''<'''	,				'''2.0.0'''	) or not hasattr(lowerCAmelCase_	,				'''_dynamo'''	):
								return False
				return isinstance(lowerCAmelCase_	,				torch._dynamo.eval_frame.OptimizedModule	)