





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






  """simple docstring"""





  if is_torch_available():
    import torch

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

  return isinstance(_UpperCAmelCase			, np.ndarray )





class 			_UpperCAmelCase  (       UpperCAmelCase__		):



      '''simple docstring'''

      def  lowerCamelCase_      (					self  ):

        """simple docstring"""

        A_  :	List[Any]    						=  fields(self  )

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

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

      def __delitem__(					self ,				*snake_case_ ,				**snake_case_  ):

        """simple docstring"""

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

      def  lowerCamelCase_      (					self ,				*snake_case_ ,				**snake_case_  ):

        """simple docstring"""

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

      def  lowerCamelCase_      (					self ,				*snake_case_ ,				**snake_case_  ):

        """simple docstring"""

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

      def  lowerCamelCase_      (					self ,				*snake_case_ ,				**snake_case_  ):

        """simple docstring"""

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

      def __getitem__(					self ,				snake_case_  ):

        """simple docstring"""

        if isinstance(snake_case_ ,				snake_case_  ):
          A_  :	str    						=  dict(self.items()  )
          return inner_dict[k]
        else:
          return self.to_tuple()[k]

      def __setattr__(					self ,				snake_case_ ,				snake_case_  ):

        """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_  ):

        """simple docstring"""

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

      def  lowerCamelCase_      (					self  ):

        """simple docstring"""

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






"""simple docstring"""




# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

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


lowerCamelCase_					:						Any      = {
    'configuration_tvlt': ['TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TvltConfig'],
    'feature_extraction_tvlt': ['TvltFeatureExtractor'],
    'processing_tvlt': ['TvltProcessor'],
}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowerCamelCase_					:						Union[str, Any]      = [
       'TVLT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'TvltModel',
       'TvltForPreTraining',
       'TvltForAudioVisualClassification',
       'TvltPreTrainedModel',
   ]

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowerCamelCase_					:						List[Any]      = ['TvltImageProcessor']


if TYPE_CHECKING:
   from .configuration_tvlt import TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP, TvltConfig
   from .processing_tvlt import TvltProcessor
   from .feature_extraction_tvlt import TvltFeatureExtractor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tvlt import (
          TVLT_PRETRAINED_MODEL_ARCHIVE_LIST,
          TvltForAudioVisualClassification,
          TvltForPreTraining,
          TvltModel,
          TvltPreTrainedModel,
      )

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .image_processing_tvlt import TvltImageProcessor


else:
   import sys

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