
from ...processing_utils import ProcessorMixin






class UpperCAmelCase   (						lowerCAmelCase_   ):





   '''simple docstring'''
   __UpperCamelCase		:    Union[str, Any] 				=    '''WhisperFeatureExtractor'''
   __UpperCamelCase		:    Any 				=    '''WhisperTokenizer'''


   def __init__(					self     :							Optional[int]			,			lowerCAmelCase_     :							Optional[int]			,			lowerCAmelCase_     :							List[Any]     ):

      """simple docstring"""
      super().__init__(__a			,			__a     )
      _A:  List[str]					=       self.feature_extractor
      _A:  Optional[int]					=       False


   def  __magic_name__				(					self     :							Tuple			,			lowerCAmelCase_     :							Any=None			,			lowerCAmelCase_     :							Dict=None			,			lowerCAmelCase_     :							Any=True     ):

      """simple docstring"""
      return self.tokenizer.get_decoder_prompt_ids(task=__a			,			language=__a			,			no_timestamps=__a     )


   def __call__(					self     :							Union[str, Any]			,			*lowerCAmelCase_     :							List[str]			,			**lowerCAmelCase_     :							Any     ):

      """simple docstring"""





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

      _A:  Union[str, Any]					=       kwargs.pop('''audio'''			,			__a     )
      _A:  Tuple					=       kwargs.pop('''sampling_rate'''			,			__a     )
      _A:  str					=       kwargs.pop('''text'''			,			__a     )
      if len(__a     ) > 0:
         _A:  Optional[Any]					=       args[0]
         _A:  List[Any]					=       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:  List[Any]					=       self.feature_extractor(__a			,			*__a			,			sampling_rate=__a			,			**__a     )
      if text is not None:
         _A:  Any					=       self.tokenizer(__a			,			**__a     )

      if text is None:
         return inputs

      elif audio is None:
         return encodings
      else:
         _A:  Tuple					=       encodings['input_ids']
         return inputs


   def  __magic_name__				(					self     :							int			,			*lowerCAmelCase_     :							Tuple			,			**lowerCAmelCase_     :							str     ):

      """simple docstring"""
      return self.tokenizer.batch_decode(*__a			,			**__a     )


   def  __magic_name__				(					self     :							int			,			*lowerCAmelCase_     :							Optional[int]			,			**lowerCAmelCase_     :							int     ):

      """simple docstring"""
      return self.tokenizer.decode(*__a			,			**__a     )


   def  __magic_name__				(					self     :							int			,			lowerCAmelCase_     :							str			,			lowerCAmelCase_     :							List[Any]="np"     ):

      """simple docstring"""
      return self.tokenizer.get_prompt_ids(__a			,			return_tensors=__a     )







'''simple docstring'''



import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_huggingface_suite,
    require_multi_gpu,
    require_single_gpu,
)
from accelerate.utils import patch_environment





@require_huggingface_suite
class 							__UpperCamelCase				(		unittest.TestCase					):




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       List[Any]					    =  inspect.getfile(accelerate.test_utils							)
						__a			:       List[str]					    =  os.path.sep.join(
						    mod_file.split(os.path.sep							)[:-1] + ['scripts', 'external_deps', 'test_metrics.py']							)

						from accelerate.test_utils.scripts.external_deps import test_metrics  # noqa: F401

						__a			:       Union[str, Any]					    =  test_metrics




	@require_cpu
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						debug_launcher(self.test_metrics.main						,				num_processes=1							)




	@require_cpu
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						debug_launcher(self.test_metrics.main							)




	@require_single_gpu
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						self.test_metrics.main()





	@require_multi_gpu
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						print(f"""Found {torch.cuda.device_count()} devices."""							)
						__a			:       List[Any]					    =  ['torchrun', f"""--nproc_per_node={torch.cuda.device_count()}""", self.test_file_path]
						with patch_environment(omp_num_threads=1							):
											execute_subprocess_async(__a						,				env=os.environ.copy()							)



