
"""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   __magic_name__     (				__snake_case    :	int  )			->    Optional[Any]:

       if is_torch_available():
              import torch

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

       return isinstance(lowercase_					,			np.ndarray  )

class 		a__						(				lowercase__						):
      def       __magic_name__      (      self    ):
             lowercase   :    List[str]			=							fields(self    )

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

             lowercase   :    Dict			=							getattr(self     ,   class_fields[0].name    )
             lowercase   :    Optional[Any]			=							all(getattr(self     ,   field.name    ) is None for field in class_fields[1:]    )

             if other_fields_are_none and isinstance(lowerCAmelCase__     ,   lowerCAmelCase__    ):
                    for key, value in first_field.items():
                           lowercase   :    Any			=							value
             else:
                    for field in class_fields:
                           lowercase   :    Optional[int]			=							getattr(self     ,   field.name    )
                           if v is not None:
                                  lowercase   :    Optional[Any]			=							v
      def __delitem__(      self     ,   *_a     ,   **_a    ):
             raise Exception(f"""You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."""    )
      def       __magic_name__      (      self     ,   *_a     ,   **_a    ):
             raise Exception(f"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""    )
      def       __magic_name__      (      self     ,   *_a     ,   **_a    ):
             raise Exception(f"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""    )
      def       __magic_name__      (      self     ,   *_a     ,   **_a    ):
             raise Exception(f"""You cannot use ``update`` on a {self.__class__.__name__} instance."""    )
      def __getitem__(      self     ,   _a    ):
             if isinstance(lowerCAmelCase__     ,   lowerCAmelCase__    ):
                    lowercase   :    Union[str, Any]			=							dict(self.items()    )
                    return inner_dict[k]
             else:
                    return self.to_tuple()[k]
      def __setattr__(      self     ,   _a     ,   _a    ):
             if name in self.keys() and value is not None:
                    # Don't call self.__setitem__ to avoid recursion errors
                    super().__setitem__(lowerCAmelCase__     ,   lowerCAmelCase__    )
             super().__setattr__(lowerCAmelCase__     ,   lowerCAmelCase__    )
      def __setitem__(      self     ,   _a     ,   _a    ):
             super().__setitem__(lowerCAmelCase__     ,   lowerCAmelCase__    )
             # Don't call self.__setattr__ to avoid recursion errors
             super().__setattr__(lowerCAmelCase__     ,   lowerCAmelCase__    )

      def       __magic_name__      (      self    ):
             return tuple(self[k] for k in self.keys()    )




"""simple docstring"""




from __future__ import annotations

_A      :	List[str]       		=	"""Alexander Joslin"""


def   __magic_name__     (				__snake_case    :	int  )			->    int:

       if number <= 0:
              lowercase   :    Optional[Any]			=							f"""n must be greater than 0. Got n = {number}"""
              raise ValueError(__snake_case  )

       lowercase   :    List[str]			=							[number + 1] * (number + 1)

       # starting position
       lowercase   :    Optional[Any]			=							0
       for i in range(1					,			__snake_case  ):
              lowercase   :    str			=							min(table[i + 1]					,			table[i] + 1  )
              # check if out of bounds
              if i * 2 <= number:
                     lowercase   :    int			=							min(table[i * 2]					,			table[i] + 1  )
              # check if out of bounds
              if i * 3 <= number:
                     lowercase   :    Optional[int]			=							min(table[i * 3]					,			table[i] + 1  )
       return table[number]


if __name__ == "__main__":
   import doctest

   doctest.testmod()


