code: 
  from functools import partial
  from typing import Any, Callable, Dict, List, Type, TypeVar, Union, overload
  
  import torch
  import torch.nn as nn
  import torch.types
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_	)			->							torch.Tensor:
  				# The first operation in a checkpoint can't be in-place, but it's
  				# nice to have in-place addition during inference. Thus...
  				if not inplace:
  								A__     :							Any   				=ma + ma
  				else:
  								ma += ma
  
  				return ma
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_	)			->							torch.Tensor:
  				A__     :							str   				=-1 * len(lowercase_	)
  				A__     :							Any   				=list(range(len(tensor.shape[:zero_index]	)	)	)
  				return tensor.permute(first_inds + [zero_index + i for i in inds]	)
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_	)			->							torch.Tensor:
  				return t.reshape(t.shape[:-no_dims] + (-1,)	)
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_,	snake_case_ = 1e-4	)			->							torch.Tensor:
  				A__     :							Any   				=mask.expand(*value.shape	)
  				return torch.sum(mask * value,	dim=lowercase_	) / (eps + torch.sum(lowercase_,	dim=lowercase_	))
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_ = 2.3_1_2_5,	snake_case_ = 2_1.6_8_7_5,	snake_case_ = 6_4	)			->							torch.Tensor:
  				A__     :							int   				=torch.linspace(lowercase_,	lowercase_,	no_bins - 1,	device=pts.device	)
  				A__     :							Optional[Any]   				=torch.sqrt(torch.sum((pts.unsqueeze(-2	) - pts.unsqueeze(-3	)) ** 2,	dim=-1	)	)
  				return torch.bucketize(lowercase_,	lowercase_	)
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_	)			->							dict:
  				A__     :							Dict   				=dicts[0]
  				A__     :							str   				={}
  				for k, v in first.items():
  								A__     :							List[Any]   				=[d[k] for d in dicts]
  								if isinstance(lowercase_,	lowercase_	):
  												A__     :							Any   				=dict_multimap(lowercase_,	lowercase_	)
  								else:
  												A__     :							Dict   				=fn(lowercase_	)
  
  				return new_dict
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_	)			->							torch.Tensor:
  				A__     :							str   				=v_bins.view(((1,) * len(x.shape	)) + (len(lowercase_	),)	)
  				A__     :							Union[str, Any]   				=x[..., None] - reshaped_bins
  				A__     :							Optional[Any]   				=torch.argmin(torch.abs(lowercase_	),	dim=-1	)
  				return nn.functional.one_hot(lowercase_,	num_classes=len(lowercase_	)	).float()
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_ = 0,	snake_case_ = 0	)			->							torch.Tensor:
  				A__     :							List[Union[slice, torch.Tensor]]   				=[]
  				for i, s in enumerate(data.shape[:no_batch_dims]	):
  								A__     :							Optional[Any]   				=torch.arange(lowercase_	)
  								A__     :							Union[str, Any]   				=r.view(*(*((1,) * i), -1, *((1,) * (len(inds.shape	) - i - 1)))	)
  								ranges.append(lowercase_	)
  
  				A__     :							List[Union[slice, torch.Tensor]]   				=[slice(lowercase_	) for _ in range(len(data.shape	) - no_batch_dims	)]
  				A__     :							Union[str, Any]   				=inds
  				ranges.extend(lowercase_	)
  				# Matt note: Editing this to get around the behaviour of using a list as an array index changing
  				# in recent Numpy versions
  				return data[tuple(lowercase_	)]
  
  
  __lowerCamelCase       :       Union[str, Any]				   =			TypeVar("T")
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_	)			->							Dict[Any, Union[dict, list, tuple, Any]]:
  				A__     :							Dict[Any, Union[dict, list, tuple, Any]]   				={}
  				for k, v in dic.items():
  								if isinstance(lowercase_,	lowercase_	):
  												A__     :							Dict   				=dict_map(lowercase_,	lowercase_,	lowercase_	)
  								else:
  												A__     :							List[Any]   				=tree_map(lowercase_,	lowercase_,	lowercase_	)
  
  				return new_dict
  
  
  
  @overload
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_	)			->							Any:
  				...
  
  
  
  @overload
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_	)			->							dict:
  				...
  
  
  
  @overload
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_	)			->							list:
  				...
  
  
  
  @overload
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_	)			->							tuple:
  				...
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_,	snake_case_,	snake_case_	)			->							Any:
  				if isinstance(lowercase_,	lowercase_	):
  								return dict_map(lowercase_,	lowercase_,	lowercase_	)
  				elif isinstance(lowercase_,	lowercase_	):
  								return [tree_map(lowercase_,	lowercase_,	lowercase_	) for x in tree]
  				elif isinstance(lowercase_,	lowercase_	):
  								return tuple(tree_map(lowercase_,	lowercase_,	lowercase_	) for x in tree	)
  				elif isinstance(lowercase_,	lowercase_	):
  								return fn(lowercase_	)
  				else:
  								print(type(lowercase_	)	)
  								raise ValueError('''Not supported'''	)
  
  
  
  
  __lowerCamelCase       :       Optional[Any]				   =			partial(tree_map, leaf_type=torch.Tensor)
  
  
  
  
style_context: 
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_	)			->							int:
  				barcode //= 1_0  # exclude the last digit
  				A__     :							List[str]   				=False
  				A__     :							Dict   				=0
  
  				# extract and check each digit
  				while barcode != 0:
  								A__     :							Union[str, Any]   				=1 if checker else 3
  								s += mult * (barcode % 1_0)
  								barcode //= 1_0
  								A__     :							Union[str, Any]   				=not checker
  
  				return (1_0 - (s % 1_0)) % 1_0
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_	)			->							bool:
  				return len(str(snake_case_	)	) == 1_3 and get_check_digit(snake_case_	) == barcode % 1_0
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_	)			->							int:
  				if str(snake_case_	).isalpha():
  								A__     :							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()
  						__lowerCamelCase       :       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.")
  
  
  
  