

import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : List[str]			       ="""Speech2TextFeatureExtractor"""
  UpperCAmelCase__      : List[str]			       ="""Speech2TextTokenizer"""


  def __init__(			self    : Dict				,				UpperCAmelCase__    : Optional[Any]				,				UpperCAmelCase__    : int		)					->Tuple:
        """simple docstring"""







        super().__init__(UpperCAmelCase__				,				UpperCAmelCase__		)
        SCREAMING_SNAKE_CASE :      Dict       =   self.feature_extractor
        SCREAMING_SNAKE_CASE :      List[str]       =   False


  def __call__(			self    : str				,				*UpperCAmelCase__    : str				,				**UpperCAmelCase__    : Tuple		)					->Optional[int]:
        """simple docstring"""







        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."""		)
              SCREAMING_SNAKE_CASE :      int       =   kwargs.pop("""raw_speech"""		)
        else:
              SCREAMING_SNAKE_CASE :      List[str]       =   kwargs.pop("""audio"""				,				UpperCAmelCase__		)
        SCREAMING_SNAKE_CASE :      str       =   kwargs.pop("""sampling_rate"""				,				UpperCAmelCase__		)
        SCREAMING_SNAKE_CASE :      List[Any]       =   kwargs.pop("""text"""				,				UpperCAmelCase__		)
        if len(UpperCAmelCase__		) > 0:
              SCREAMING_SNAKE_CASE :      Optional[Any]       =   args[0]
              SCREAMING_SNAKE_CASE :      str       =   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:
              SCREAMING_SNAKE_CASE :      Dict       =   self.feature_extractor(UpperCAmelCase__				,				*UpperCAmelCase__				,				sampling_rate=UpperCAmelCase__				,				**UpperCAmelCase__		)
        if text is not None:
              SCREAMING_SNAKE_CASE :      Optional[Any]       =   self.tokenizer(UpperCAmelCase__				,				**UpperCAmelCase__		)

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


  def  _lowercase      (			self    : List[Any]				,				*UpperCAmelCase__    : Dict				,				**UpperCAmelCase__    : Dict		)					->Tuple:
        """simple docstring"""







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


  def  _lowercase      (			self    : int				,				*UpperCAmelCase__    : List[Any]				,				**UpperCAmelCase__    : Dict		)					->int:
        """simple docstring"""







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




  @contextmanager
  def  _lowercase      (			self    : Tuple		)					->Optional[Any]:
        """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."""		)
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   True
        SCREAMING_SNAKE_CASE :      Tuple       =   self.tokenizer
        yield
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   self.feature_extractor
        SCREAMING_SNAKE_CASE :      Any       =   False







from __future__ import annotations

import numpy as np






def 					__lowercase      (     _A			)     ->						tuple[np.ndarray, np.ndarray]:
      SCREAMING_SNAKE_CASE     ,	SCREAMING_SNAKE_CASE :      Dict       =   np.shape(_A			)
      if rows != columns:
            SCREAMING_SNAKE_CASE :      int       =   (
                """'table' has to be of square shaped array but got a """
                F"{rows}x{columns} array:\n{table}"
            )
            raise ValueError(_A			)

      SCREAMING_SNAKE_CASE :      Union[str, Any]       =   np.zeros((rows, columns)			)
      SCREAMING_SNAKE_CASE :      Optional[Any]       =   np.zeros((rows, columns)			)
      for i in range(_A			):
            for j in range(_A			):
                  SCREAMING_SNAKE_CASE :      Tuple       =   sum(lower[i][k] * upper[k][j] for k in range(_A			)			)
                  if upper[j][j] == 0:
                        raise ArithmeticError("""No LU decomposition exists"""			)
                  SCREAMING_SNAKE_CASE :      Union[str, Any]       =   (table[i][j] - total) / upper[j][j]
            SCREAMING_SNAKE_CASE :      Optional[Any]       =   1
            for j in range(_A						,    _A			):
                  SCREAMING_SNAKE_CASE :      List[str]       =   sum(lower[i][k] * upper[k][j] for k in range(_A			)			)
                  SCREAMING_SNAKE_CASE :      Optional[Any]       =   table[i][j] - total
      return lower, upper


if __name__ == "__main__":
  import doctest

  doctest.testmod()




