'''simple docstring'''






import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin







class lowercase_       (		_UpperCamelCase			):







   """simple docstring"""

   __lowerCAmelCase         =   "MCTCTFeatureExtractor"
   __lowerCAmelCase         =   "AutoTokenizer"
   def __init__(      self      :			Optional[int], UpperCamelCase__      :			Dict, UpperCamelCase__      :			Union[str, Any]     )  ->			Dict:
        super().__init__(UpperCamelCase__, UpperCamelCase__     )
        _A    		=  self.feature_extractor
        _A    		=  False
   def __call__(      self      :			Any, *UpperCamelCase__      :			Any, **UpperCamelCase__      :			Optional[int]     )  ->			List[Any]:
        # For backward compatibility
        if self._in_target_context_manager:
             return self.current_processor(*UpperCamelCase__, **UpperCamelCase__     )

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

        if text is None:
             return inputs
        elif audio is None:
             return encodings
        else:
             _A    		=  encodings['input_ids']
             return inputs
   def 	__UpperCAmelCase   (      self      :			str, *UpperCamelCase__      :			Any, **UpperCamelCase__      :			Optional[int]     )  ->			List[str]:
        return self.tokenizer.batch_decode(*UpperCamelCase__, **UpperCamelCase__     )
   def 	__UpperCAmelCase   (      self      :			Any, *UpperCamelCase__      :			Union[str, Any], **UpperCamelCase__      :			Tuple     )  ->			Union[str, Any]:
        # For backward compatibility
        if self._in_target_context_manager:
             return self.current_processor.pad(*UpperCamelCase__, **UpperCamelCase__     )

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

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

        if labels is None:
             return input_features
        elif input_features is None:
             return labels
        else:
             _A    		=  labels['input_ids']
             return input_features
   def 	__UpperCAmelCase   (      self      :			List[Any], *UpperCamelCase__      :			int, **UpperCamelCase__      :			Tuple     )  ->			List[Any]:
        return self.tokenizer.decode(*UpperCamelCase__, **UpperCamelCase__     )

   @contextmanager
   def 	__UpperCAmelCase   (      self      :			List[str]     )  ->			Optional[Any]:
        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    		=  True
        _A    		=  self.tokenizer
        yield
        _A    		=  self.feature_extractor
        _A    		=  False




'''simple docstring'''






_UpperCAmelCase    :     Any         =       '''0.21.0'''

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
   from .utils import rich



