'''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_						( snake_case_	:	List[str]				) ->					List[Any]:






 '''simple docstring'''

 if is_torch_available():
  import torch

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

 return isinstance(snake_case_						,		np.ndarray				)







class     _lowercase					(    UpperCAmelCase__      ):


 '''simple docstring'''






 def a (				self       :     Tuple							)  ->   Union[str, Any]:
  __lowerCAmelCase    							=						fields(self							)

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

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

  if other_fields_are_none and isinstance(SCREAMING_SNAKE_CASE__				,	SCREAMING_SNAKE_CASE__							):
   for key, value in first_field.items():
    __lowerCAmelCase    							=						value
  else:
   for field in class_fields:
    __lowerCAmelCase    							=						getattr(self				,	field.name							)
    if v is not None:
     __lowerCAmelCase    							=						v
 def __delitem__(				self       :     List[Any]				,	*SCREAMING_SNAKE_CASE__       :     str				,	**SCREAMING_SNAKE_CASE__       :     Tuple							)  ->   Dict:
  raise Exception(f"""You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."""							)
 def a (				self       :     List[Any]				,	*SCREAMING_SNAKE_CASE__       :     List[str]				,	**SCREAMING_SNAKE_CASE__       :     List[Any]							)  ->   Any:
  raise Exception(f"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""							)
 def a (				self       :     int				,	*SCREAMING_SNAKE_CASE__       :     List[str]				,	**SCREAMING_SNAKE_CASE__       :     Optional[Any]							)  ->   Optional[Any]:
  raise Exception(f"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""							)
 def a (				self       :     Tuple				,	*SCREAMING_SNAKE_CASE__       :     Optional[Any]				,	**SCREAMING_SNAKE_CASE__       :     List[Any]							)  ->   Dict:
  raise Exception(f"""You cannot use ``update`` on a {self.__class__.__name__} instance."""							)
 def __getitem__(				self       :     Any				,	SCREAMING_SNAKE_CASE__       :     List[str]							)  ->   Any:
  if isinstance(SCREAMING_SNAKE_CASE__				,	SCREAMING_SNAKE_CASE__							):
   __lowerCAmelCase    							=						dict(self.items()							)
   return inner_dict[k]
  else:
   return self.to_tuple()[k]
 def __setattr__(				self       :     Optional[Any]				,	SCREAMING_SNAKE_CASE__       :     Any				,	SCREAMING_SNAKE_CASE__       :     str							)  ->   List[str]:
  if name in self.keys() and value is not None:
   # Don't call self.__setitem__ to avoid recursion errors
   super().__setitem__(SCREAMING_SNAKE_CASE__				,	SCREAMING_SNAKE_CASE__							)
  super().__setattr__(SCREAMING_SNAKE_CASE__				,	SCREAMING_SNAKE_CASE__							)
 def __setitem__(				self       :     List[str]				,	SCREAMING_SNAKE_CASE__       :     Any				,	SCREAMING_SNAKE_CASE__       :     List[str]							)  ->   Tuple:
  # Will raise a KeyException if needed
  super().__setitem__(SCREAMING_SNAKE_CASE__				,	SCREAMING_SNAKE_CASE__							)
  # Don't call self.__setattr__ to avoid recursion errors
  super().__setattr__(SCREAMING_SNAKE_CASE__				,	SCREAMING_SNAKE_CASE__							)





 def a (				self       :     Optional[int]							)  ->   Tuple[Any]:
  return tuple(self[k] for k in self.keys()							)







'''simple docstring'''

from typing import TYPE_CHECKING

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


_A      :				Optional[int] 				=    {
    '''configuration_speech_to_text_2''': ['''SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Speech2Text2Config'''],
    '''processing_speech_to_text_2''': ['''Speech2Text2Processor'''],
    '''tokenization_speech_to_text_2''': ['''Speech2Text2Tokenizer'''],
}


try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _A      :				Any 				=    [
     '''SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''Speech2Text2ForCausalLM''',
     '''Speech2Text2PreTrainedModel''',
 ]


if TYPE_CHECKING:
 from .configuration_speech_to_text_a import SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextaConfig
 from .processing_speech_to_text_a import SpeechaTextaProcessor
 from .tokenization_speech_to_text_a import SpeechaTextaTokenizer

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_speech_to_text_a import (
      SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST,
      SpeechaTextaForCausalLM,
      SpeechaTextaPreTrainedModel,
  )

else:
 import sys

 _A      :				Tuple 				=    _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)






