



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()				)






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


A_		:  Any										=  {
    '''configuration_align''': [
        '''ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''AlignConfig''',
        '''AlignTextConfig''',
        '''AlignVisionConfig''',
    ],
    '''processing_align''': ['''AlignProcessor'''],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A_		:  Optional[int]										=  [
         '''ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''AlignModel''',
         '''AlignPreTrainedModel''',
         '''AlignTextModel''',
         '''AlignVisionModel''',
     ]

if TYPE_CHECKING:
     from .configuration_align import (
         ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP,
         AlignConfig,
         AlignTextConfig,
         AlignVisionConfig,
     )
     from .processing_align import AlignProcessor

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_align import (
              ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST,
              AlignModel,
              AlignPreTrainedModel,
              AlignTextModel,
              AlignVisionModel,
          )

else:
     import sys

     A_		:  int										=  _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)

