"""simple docstring"""


from __future__ import annotations

from enum import Enum, unique
from typing import TypeVar

# Create a generic variable that can be 'Enum', or any subclass.
a							=TypeVar('T', bound='Enum')






@unique
class    __UpperCAmelCase						(	__lowerCAmelCase	):
				A__      :   int  							=       8_0
				A__      :   Dict  							=       7_0
				A__      :   List[Any]  							=       6_0
				A__      :   Dict  							=       5_0
				A__      :   Dict  							=       4_0
				A__      :   Tuple  							=       3_0
				A__      :   Dict  							=       2_0
				A__      :   Any  							=       1_0






@unique
class    __UpperCAmelCase						(	__lowerCAmelCase	):
				A__      :   Dict  							=       2_4
				A__      :   Union[str, Any]  							=       2_1
				A__      :   Dict  							=       1_8
				A__      :   Any  							=       1_5
				A__      :   Dict  							=       1_2
				A__      :   Dict  							=       9
				A__      :   Tuple  							=       6
				A__      :   Tuple  							=       3
				A__      :   Dict  							=       2
				A__      :   Dict  							=       1
				A__      :   List[Any]  							=       -1
				A__      :   str  							=       -2
				A__      :   Union[str, Any]  							=       -3
				A__      :   Optional[int]  							=       -6
				A__      :   int  							=       -9
				A__      :   Dict  							=       -1_2
				A__      :   List[str]  							=       -1_5
				A__      :   str  							=       -1_8
				A__      :   str  							=       -2_1
				A__      :   List[Any]  							=       -2_4

				@classmethod
				def 		_a	(      cls      ):
										return {unit.name: unit.value for unit in cls if unit.value > 0}






				@classmethod
				def 		_a	(      cls      ):
										return {unit.name: unit.value for unit in cls if unit.value < 0}





def 			lowerCamelCase_ (					__lowerCAmelCase				)							->					str:




						'''simple docstring'''



						lowerCamelCase__					=SIUnit.get_positive() if value > 0 else SIUnit.get_negative()
						for name_prefix, value_prefix in prefixes.items():
												lowerCamelCase__					=value / (10**value_prefix)
												if numerical_part > 1:
																		return F'''{numerical_part!s} {name_prefix}'''
						return str(__lowerCAmelCase				)





def 			lowerCamelCase_ (					__lowerCAmelCase				)							->					str:




						'''simple docstring'''



						for prefix in BinaryUnit:
												lowerCamelCase__					=value / (2**prefix.value)
												if numerical_part > 1:
																		return F'''{numerical_part!s} {prefix.name}'''
						return str(__lowerCAmelCase				)


if __name__ == "__main__":
	import doctest

	doctest.testmod()










"""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				(					lowerCAmelCase						):







       '''simple docstring'''
       if is_torch_available():
              import torch

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

       return isinstance(lowerCAmelCase		,					np.ndarray						)





class      UpperCamelCase_       (				a_     ):



  def 						UpperCamelCase_ (					self )	->	Dict:



         """simple docstring"""





         UpperCAmelCase					=	fields(self )

         # Safety and consistency checks
         if not len(snake_case__ ):
                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(snake_case__       ,						snake_case__ ):
                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       ,						*snake_case__       ,						**snake_case__ )	->	Optional[int]:



         """simple docstring"""





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



  def 						UpperCamelCase_ (					self       ,						*snake_case__       ,						**snake_case__ )	->	List[str]:



         """simple docstring"""





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



  def 						UpperCamelCase_ (					self       ,						*snake_case__       ,						**snake_case__ )	->	Optional[int]:



         """simple docstring"""





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



  def 						UpperCamelCase_ (					self       ,						*snake_case__       ,						**snake_case__ )	->	Optional[int]:



         """simple docstring"""





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



  def __getitem__(					self       ,						snake_case__ )	->	List[Any]:



         """simple docstring"""





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



  def __setattr__(					self       ,						snake_case__       ,						snake_case__ )	->	Union[str, Any]:



         """simple docstring"""





         if name in self.keys() and value is not None:
                # Don't call self.__setitem__ to avoid recursion errors
                super().__setitem__(snake_case__       ,						snake_case__ )
         super().__setattr__(snake_case__       ,						snake_case__ )



  def __setitem__(					self       ,						snake_case__       ,						snake_case__ )	->	Tuple:



         """simple docstring"""





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



  def 						UpperCamelCase_ (					self )	->	Tuple[Any]:



         """simple docstring"""





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