'''simple docstring'''




from collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available




def 				lowerCamelCase      ( UpperCAmelCase__			:   Optional[Any]					)     -> Optional[Any]:
							if is_torch_available():
														import torch

														if isinstance(snake_case_ , torch.Tensor					):
																					return True

							return isinstance(snake_case_ , np.ndarray					)





class        __magic_name__		(       _lowerCAmelCase):







			def       SCREAMING_SNAKE_CASE_	(      self							:    Any       ):
										lowercase_   :     Dict									=			fields(self       )

										# Safety and consistency checks
										if not len(_UpperCAmelCase       ):
																	raise ValueError(f'''{self.__class__.__name__} has no fields.'''       )

										lowercase_   :     int									=			getattr(self							,     class_fields[0].name       )
										lowercase_   :     Union[str, Any]									=			all(getattr(self							,     field.name       ) is None for field in class_fields[1:]       )

										if other_fields_are_none and isinstance(_UpperCAmelCase							,     _UpperCAmelCase       ):
																	for key, value in first_field.items():
																								lowercase_   :     str									=			value
										else:
																	for field in class_fields:
																								lowercase_   :     Optional[Any]									=			getattr(self							,     field.name       )
																								if v is not None:
																															lowercase_   :     Optional[Any]									=			v







			def __delitem__(      self							:    List[str]							,     *lowercase_							:    Any							,     **lowercase_							:    Tuple       ):
										raise Exception(f'''You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.'''       )







			def       SCREAMING_SNAKE_CASE_	(      self							:    int							,     *lowercase_							:    Optional[Any]							,     **lowercase_							:    Optional[Any]       ):
										raise Exception(f'''You cannot use ``setdefault`` on a {self.__class__.__name__} instance.'''       )







			def       SCREAMING_SNAKE_CASE_	(      self							:    List[str]							,     *lowercase_							:    Optional[int]							,     **lowercase_							:    Any       ):
										raise Exception(f'''You cannot use ``pop`` on a {self.__class__.__name__} instance.'''       )







			def       SCREAMING_SNAKE_CASE_	(      self							:    str							,     *lowercase_							:    Optional[Any]							,     **lowercase_							:    int       ):
										raise Exception(f'''You cannot use ``update`` on a {self.__class__.__name__} instance.'''       )







			def __getitem__(      self							:    str							,     lowercase_							:    Tuple       ):
										if isinstance(_UpperCAmelCase							,     _UpperCAmelCase       ):
																	lowercase_   :     List[Any]									=			dict(self.items()       )
																	return inner_dict[k]
										else:
																	return self.to_tuple()[k]







			def __setattr__(      self							:    Union[str, Any]							,     lowercase_							:    str							,     lowercase_							:    str       ):
										if name in self.keys() and value is not None:
																	# Don't call self.__setitem__ to avoid recursion errors
																	super().__setitem__(_UpperCAmelCase							,     _UpperCAmelCase       )
										super().__setattr__(_UpperCAmelCase							,     _UpperCAmelCase       )







			def __setitem__(      self							:    Optional[int]							,     lowercase_							:    Optional[Any]							,     lowercase_							:    Any       ):
										# Will raise a KeyException if needed
										super().__setitem__(_UpperCAmelCase							,     _UpperCAmelCase       )
										# Don't call self.__setattr__ to avoid recursion errors
										super().__setattr__(_UpperCAmelCase							,     _UpperCAmelCase       )







			def       SCREAMING_SNAKE_CASE_	(      self							:    List[Any]       ):
										return tuple(self[k] for k in self.keys()       )








from __future__ import annotations





def  _snake_case		(snake_case_					:     str  )							->		bool:
  __UpperCAmelCase	:  int
  __UpperCAmelCase	:  list[str]		=     list(snake_case_  )
  __UpperCAmelCase,			__UpperCAmelCase	:  Any		=     _vector[:-1], int(_vector[-1]  )
  __UpperCAmelCase	:  list[int]		=     [int(snake_case_  ) for digit in __vector]

  vector.reverse()
  for i, digit in enumerate(snake_case_  ):
    if i & 1 == 0:
      __UpperCAmelCase	:  int		=     digit * 2
      if doubled > 9:
        doubled -= 9
      check_digit += doubled
    else:
      check_digit += digit

  return check_digit % 10 == 0


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      assert is_luhn('''79927398713''')
      assert not is_luhn('''79927398714''')





