




'''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,
)


UpperCamelCase			     =					{
    '''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:
     UpperCamelCase			     =					[
         '''TVLT_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''TvltModel''',
         '''TvltForPreTraining''',
         '''TvltForAudioVisualClassification''',
         '''TvltPreTrainedModel''',
     ]

try:
     if not is_vision_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCamelCase			     =					['''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

     UpperCamelCase			     =					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)












'''simple docstring'''


import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin






class 						lowerCAmelCase_	(       UpperCAmelCase_							):







  '''simple docstring'''

  UpperCamelCase_			:      Optional[int]										=				"""AutoFeatureExtractor"""
  UpperCamelCase_			:      List[Any]										=				"""Speech2Text2Tokenizer"""



  def __init__( self				:							str					,  SCREAMING_SNAKE_CASE_				:							str					,  SCREAMING_SNAKE_CASE_				:							int	)			->		Any:







       '''simple docstring'''



       super().__init__(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_	)
       A:		Union[str, Any]          =		self.feature_extractor
       A:		Dict          =		False



  def __call__( self				:							Any					,  *SCREAMING_SNAKE_CASE_				:							Any					,  **SCREAMING_SNAKE_CASE_				:							Optional[int]	)			->		Optional[Any]:







       '''simple docstring'''



       if self._in_target_context_manager:
            return self.current_processor(*SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_	)

       if "raw_speech" in kwargs:
            warnings.warn('''Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'''	)
            A:		List[str]          =		kwargs.pop('''raw_speech'''	)
       else:
            A:		Any          =		kwargs.pop('''audio'''					,  SCREAMING_SNAKE_CASE_	)
       A:		List[Any]          =		kwargs.pop('''sampling_rate'''					,  SCREAMING_SNAKE_CASE_	)
       A:		Optional[int]          =		kwargs.pop('''text'''					,  SCREAMING_SNAKE_CASE_	)
       if len(SCREAMING_SNAKE_CASE_	) > 0:
            A:		str          =		args[0]
            A:		Tuple          =		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:
            A:		Tuple          =		self.feature_extractor(SCREAMING_SNAKE_CASE_					,  *SCREAMING_SNAKE_CASE_					,  sampling_rate=SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_	)
       if text is not None:
            A:		List[Any]          =		self.tokenizer(SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_	)

       if text is None:
            return inputs
       elif audio is None:
            return encodings
       else:
            A:		str          =		encodings['''input_ids''']
            return inputs



  def 					_snake_case     ( self				:							Tuple					,  *SCREAMING_SNAKE_CASE_				:							int					,  **SCREAMING_SNAKE_CASE_				:							Union[str, Any]	)			->		str:







       '''simple docstring'''



       return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_	)



  def 					_snake_case     ( self				:							Optional[int]					,  *SCREAMING_SNAKE_CASE_				:							str					,  **SCREAMING_SNAKE_CASE_				:							int	)			->		Union[str, Any]:







       '''simple docstring'''



       return self.tokenizer.decode(*SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_	)




  @contextmanager
  def 					_snake_case     ( self				:							str	)			->		int:







       '''simple docstring'''



       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.'''	)
       A:		List[Any]          =		True
       A:		List[str]          =		self.tokenizer
       yield
       A:		List[Any]          =		self.feature_extractor
       A:		int          =		False






