'''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 						__snake_case (       lowerCAmelCase       :     List[Any]			):
 if is_torch_available():
  import torch

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

 return isinstance(lowerCAmelCase      ,  np.ndarray			)

class   _lowercase(     _lowerCamelCase				):



   """simple docstring"""





   def 			snake_case	(							self:    Dict	):
    __UpperCAmelCase         =					fields(self	)

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

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

    if other_fields_are_none and isinstance(a			,a	):
     for key, value in first_field.items():
      __UpperCAmelCase         =					value
    else:
     for field in class_fields:
      __UpperCAmelCase         =					getattr(self			,field.name	)
      if v is not None:
       __UpperCAmelCase         =					v





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





   def 			snake_case	(							self:    Union[str, Any]			,*a:    List[str]			,**a:    Optional[Any]	):
    raise Exception(f"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""	)





   def 			snake_case	(							self:    Any			,*a:    str			,**a:    Dict	):
    raise Exception(f"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""	)





   def 			snake_case	(							self:    str			,*a:    Tuple			,**a:    List[str]	):
    raise Exception(f"""You cannot use ``update`` on a {self.__class__.__name__} instance."""	)





   def __getitem__(							self:    Any			,a:    Tuple	):
    if isinstance(a			,a	):
     __UpperCAmelCase         =					dict(self.items()	)
     return inner_dict[k]
    else:
     return self.to_tuple()[k]





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





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





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




'''simple docstring'''




def 						__snake_case (       lowerCAmelCase       :     str			):
 __UpperCAmelCase         =					5381
 for x in s:
  __UpperCAmelCase         =					((hash_value << 5) + hash_value) + ord(lowerCAmelCase			)
 return hash_value & 0Xffff_ffff



