



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 						UpperCAmelCase__   (   UpperCAmelCase__			:Tuple       ):






 '''simple docstring'''

 if is_torch_available():
  import torch

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

 return isinstance(UpperCAmelCase__			,       np.ndarray       )




class 		_lowercase		(							UpperCAmelCase__						):

   def 		A				(   self      :							List[Any]				)							->					Tuple:


    """simple docstring"""






    a							=		fields(self				)

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

    a							=		getattr(self				, class_fields[0].name				)
    a							=		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():
      a							=		value
    else:
     for field in class_fields:
      a							=		getattr(self				, field.name				)
      if v is not None:
       a							=		v

   def __delitem__(   self      :							str				, *__lowerCAmelCase      :							int				, **__lowerCAmelCase      :							List[Any]				)							->					List[str]:


    """simple docstring"""






    raise Exception(f"""You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."""				)

   def 		A				(   self      :							Tuple				, *__lowerCAmelCase      :							Union[str, Any]				, **__lowerCAmelCase      :							Union[str, Any]				)							->					Any:


    """simple docstring"""






    raise Exception(f"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""				)

   def 		A				(   self      :							Any				, *__lowerCAmelCase      :							Union[str, Any]				, **__lowerCAmelCase      :							Any				)							->					int:


    """simple docstring"""






    raise Exception(f"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""				)

   def 		A				(   self      :							List[Any]				, *__lowerCAmelCase      :							Optional[Any]				, **__lowerCAmelCase      :							int				)							->					List[Any]:


    """simple docstring"""






    raise Exception(f"""You cannot use ``update`` on a {self.__class__.__name__} instance."""				)

   def __getitem__(   self      :							str				, __lowerCAmelCase      :							Tuple				)							->					Tuple:


    """simple docstring"""






    if isinstance(__lowerCAmelCase				, __lowerCAmelCase				):
     a							=		dict(self.items()				)
     return inner_dict[k]
    else:
     return self.to_tuple()[k]

   def __setattr__(   self      :							Dict				, __lowerCAmelCase      :							Optional[Any]				, __lowerCAmelCase      :							str				)							->					Optional[int]:


    """simple docstring"""






    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      :							List[Any]				, __lowerCAmelCase      :							Any				, __lowerCAmelCase      :							List[Any]				)							->					str:


    """simple docstring"""






    super().__setitem__(__lowerCAmelCase				, __lowerCAmelCase				)
    # Don't call self.__setattr__ to avoid recursion errors
    super().__setattr__(__lowerCAmelCase				, __lowerCAmelCase				)




   def 		A				(   self      :							Dict				)							->					Tuple[Any]:


    """simple docstring"""






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









"""simple docstring"""


from __future__ import annotations




def      snake_case    (A_ :int ):







  '''simple docstring'''

  assert (
      isinstance(A_      ,     A_ ) and mask > 0
  ), f'''mask needs to be positive integer, your input {mask}'''
  a	:     Any							=  []
  a	:     Union[str, Any]							=  mask

  while submask:
    all_submasks.append(A_ )
    a	:     Any							=  (submask - 1) & mask

  return all_submasks


if __name__ == "__main__":
   import doctest

   doctest.testmod()




