
import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin







class 					lowerCamelCase		(  A_  ):
     UpperCAmelCase__    :							int									=		"MCTCTFeatureExtractor"
     UpperCAmelCase__    :							List[Any]									=		"AutoTokenizer"





     def __init__(self				:   int    ,   _A				:   Dict    ,   _A				:   Optional[Any]       )						->						int:
         super().__init__(_A    ,   _A       )
         snake_case								= self.feature_extractor
         snake_case								= False





     def __call__(self				:   List[Any]    ,   *_A				:   int    ,   **_A				:   List[str]       )						->						Union[str, Any]:
         # For backward compatibility
         if self._in_target_context_manager:
             return self.current_processor(*_A    ,   **_A       )

         if "raw_speech" in kwargs:
             warnings.warn("Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."       )
             snake_case								= kwargs.pop("raw_speech"       )
         else:
             snake_case								= kwargs.pop("audio"    ,   _A       )
         snake_case								= kwargs.pop("sampling_rate"    ,   _A       )
         snake_case								= kwargs.pop("text"    ,   _A       )
         if len(_A       ) > 0:
             snake_case								= args[0]
             snake_case								= args[1:]

         if audio is None and text is None:
             raise ValueError("You need to specify either an `audio` or `text` input to process."       )

         if audio is not None:
             snake_case								= self.feature_extractor(_A    ,   *_A    ,   sampling_rate=_A    ,   **_A       )
         if text is not None:
             snake_case								= self.tokenizer(_A    ,   **_A       )

         if text is None:
             return inputs
         elif audio is None:
             return encodings
         else:
             snake_case								= encodings["input_ids"]
             return inputs





     def 		UpperCAmelCase(self				:   str    ,   *_A				:   List[str]    ,   **_A				:   Any       )						->						int:
         return self.tokenizer.batch_decode(*_A    ,   **_A       )





     def 		UpperCAmelCase(self				:   int    ,   *_A				:   Union[str, Any]    ,   **_A				:   Optional[Any]       )						->						Any:
         # For backward compatibility
         if self._in_target_context_manager:
             return self.current_processor.pad(*_A    ,   **_A       )

         snake_case								= kwargs.pop("input_features"    ,   _A       )
         snake_case								= kwargs.pop("labels"    ,   _A       )
         if len(_A       ) > 0:
             snake_case								= args[0]
             snake_case								= args[1:]

         if input_features is not None:
             snake_case								= self.feature_extractor.pad(_A    ,   *_A    ,   **_A       )
         if labels is not None:
             snake_case								= self.tokenizer.pad(_A    ,   **_A       )

         if labels is None:
             return input_features
         elif input_features is None:
             return labels
         else:
             snake_case								= labels["input_ids"]
             return input_features





     def 		UpperCAmelCase(self				:   Union[str, Any]    ,   *_A				:   List[str]    ,   **_A				:   Union[str, Any]       )						->						Optional[Any]:
         return self.tokenizer.decode(*_A    ,   **_A       )





     @contextmanager
     def 		UpperCAmelCase(self				:   Optional[int]       )						->						List[str]:
         warnings.warn(
             "`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your "
             "labels by using the argument `text` of the regular `__call__` method (either in the same call as "
             "your audio inputs, or in a separate call."       )
         snake_case								= True
         snake_case								= self.tokenizer
         yield
         snake_case								= self.feature_extractor
         snake_case								= False



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_A   =			{
    "configuration_lilt": ["LILT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LiltConfig"],
}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _A   =			[
       "LILT_PRETRAINED_MODEL_ARCHIVE_LIST",
       "LiltForQuestionAnswering",
       "LiltForSequenceClassification",
       "LiltForTokenClassification",
       "LiltModel",
       "LiltPreTrainedModel",
   ]

if TYPE_CHECKING:
   from .configuration_lilt import LILT_PRETRAINED_CONFIG_ARCHIVE_MAP, LiltConfig

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_lilt import (
          LILT_PRETRAINED_MODEL_ARCHIVE_LIST,
          LiltForQuestionAnswering,
          LiltForSequenceClassification,
          LiltForTokenClassification,
          LiltModel,
          LiltPreTrainedModel,
      )

else:
   import sys

   _A   =			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)

