





import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin






class        snake_case_    (		__lowercase						):
  A_      							=   'Speech2TextFeatureExtractor'
  A_      							=   'Speech2TextTokenizer'






  def __init__(							self			:					List[str]       ,  _snake_case			:					Dict       ,  _snake_case			:					Tuple      )->Optional[Any]:






   '''simple docstring'''

   super().__init__(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	str      =       self.feature_extractor
   __lowerCAmelCase					:	Union[str, Any]      =       False






  def __call__(							self			:					Dict       ,  *_snake_case			:					List[Any]       ,  **_snake_case			:					Any      )->Dict:






   '''simple docstring'''

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

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

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






  def 				UpperCAmelCase__						(							self			:					Union[str, Any]       ,  *_snake_case			:					str       ,  **_snake_case			:					str      )->List[Any]:






   '''simple docstring'''

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






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






   '''simple docstring'''

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






  @contextmanager
  def 				UpperCAmelCase__						(							self			:					List[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."""      )
   __lowerCAmelCase					:	str      =       True
   __lowerCAmelCase					:	List[Any]      =       self.tokenizer
   yield
   __lowerCAmelCase					:	Any      =       self.feature_extractor
   __lowerCAmelCase					:	Tuple      =       False






_UpperCAmelCase             =							{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

_UpperCAmelCase             =							{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:dict[int, list[int]]   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:list[bool]   )      ->   list[int]:
 __lowerCAmelCase					:	str      =       True
 __lowerCAmelCase					:	str      =       []

 for neighbour in graph[vert]:
  if not visited[neighbour]:
   order += topology_sort(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )

 order.append(SCREAMING_SNAKE_CASE   )

 return order






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:dict[int, list[int]]   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:list[bool]   )      ->   list[int]:
 __lowerCAmelCase					:	Optional[Any]      =       True
 __lowerCAmelCase					:	Union[str, Any]      =       [vert]

 for neighbour in reversed_graph[vert]:
  if not visited[neighbour]:
   component += find_components(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )

 return component







def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:dict[int, list[int]]   )      ->   list[list[int]]:
 __lowerCAmelCase					:	Optional[Any]      =       len(SCREAMING_SNAKE_CASE   ) * [False]
 __lowerCAmelCase					:	dict[int, list[int]]      =       {vert: [] for vert in range(len(SCREAMING_SNAKE_CASE   )   )}

 for vert, neighbours in graph.items():
  for neighbour in neighbours:
   reversed_graph[neighbour].append(SCREAMING_SNAKE_CASE   )

 __lowerCAmelCase					:	Tuple      =       []
 for i, was_visited in enumerate(SCREAMING_SNAKE_CASE   ):
  if not was_visited:
   order += topology_sort(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )

 __lowerCAmelCase					:	Optional[Any]      =       []
 __lowerCAmelCase					:	Any      =       len(SCREAMING_SNAKE_CASE   ) * [False]

 for i in range(len(SCREAMING_SNAKE_CASE   )   ):
  __lowerCAmelCase					:	Optional[int]      =       order[len(SCREAMING_SNAKE_CASE   ) - i - 1]
  if not visited[vert]:
   __lowerCAmelCase					:	Any      =       find_components(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )
   components_list.append(SCREAMING_SNAKE_CASE   )

 return components_list