





import argparse
import os

from accelerate.utils import ComputeEnvironment

from .cluster import get_cluster_input
from .config_args import cache_dir, default_config_file, default_yaml_config_file, load_config_from_file  # noqa: F401
from .config_utils import _ask_field, _ask_options, _convert_compute_environment  # noqa: F401
from .sagemaker import get_sagemaker_input


_lowercase       						=			'Launches a series of prompts to create and save a `default_config.yaml` configuration file for your training system. Should always be ran first on your machine'

def    __UpperCamelCase	(	) ->Dict:
 snake_case				=			_ask_options(
     '''In which compute environment are you running?'''					,   ['''This machine''', '''AWS (Amazon SageMaker)''']					,   _convert_compute_environment					,   )
 if compute_environment == ComputeEnvironment.AMAZON_SAGEMAKER:
  snake_case				=			get_sagemaker_input()
 else:
  snake_case				=			get_cluster_input()
 return config

def    __UpperCamelCase	(	a    : List[str]=None     ) ->int:
 if subparsers is not None:
  snake_case				=			subparsers.add_parser('''config'''					,   description=a     )
 else:
  snake_case				=			argparse.ArgumentParser('''Accelerate config command'''					,   description=a     )

 parser.add_argument(
     '''--config_file'''					,   default=a					,   help=(
         '''The path to use to store the config file. Will default to a file named default_config.yaml in the cache '''
         '''location, which is the content of the environment `HF_HOME` suffixed with \'accelerate\', or if you don\'t have '''
         '''such an environment variable, your cache directory (\'~/.cache\' or the content of `XDG_CACHE_HOME`) suffixed '''
         '''with \'huggingface\'.'''
     )					,   )

 if subparsers is not None:
  parser.set_defaults(func=a     )
 return parser

def    __UpperCamelCase	(	a    : Union[str, Any]     ) ->Optional[int]:
 snake_case				=			get_user_input()
 if args.config_file is not None:
  snake_case				=			args.config_file
 else:
  if not os.path.isdir(a     ):
   os.makedirs(a     )
  snake_case				=			default_yaml_config_file

 if config_file.endswith('''.json'''     ):
  config.to_json_file(a     )
 else:
  config.to_yaml_file(a     )
 print(f"""accelerate configuration saved at {config_file}"""     )

def    __UpperCamelCase	(	) ->Dict:
 snake_case				=			config_command_parser()
 snake_case				=			parser.parse_args()
 config_command(a     )


if __name__ == "__main__":
   main()








'''simple docstring'''







from ...processing_utils import ProcessorMixin
class 			_lowercase						(       __a					):
     _UpperCAmelCase										=					'''WhisperFeatureExtractor'''
     _UpperCAmelCase										=					'''WhisperTokenizer'''







     def __init__( self    ,   A__    ,   A__    ) ->	Optional[Any]:
      super().__init__(A__    ,   A__    )
      snake_case				=			self.feature_extractor
      snake_case				=			False







     def     UpperCamelCase			( self    ,   A__=None    ,   A__=None    ,   A__=True    ) ->	Union[str, Any]:
      return self.tokenizer.get_decoder_prompt_ids(task=A__    ,   language=A__    ,   no_timestamps=A__    )







     def __call__( self    ,   *A__    ,   **A__    ) ->	Dict:
      # For backward compatibility
      if self._in_target_context_manager:
       return self.current_processor(*A__    ,   **A__    )

      snake_case				=			kwargs.pop('''audio'''    ,   A__    )
      snake_case				=			kwargs.pop('''sampling_rate'''    ,   A__    )
      snake_case				=			kwargs.pop('''text'''    ,   A__    )
      if len(A__    ) > 0:
       snake_case				=			args[0]
       snake_case				=			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:
       snake_case				=			self.feature_extractor(A__    ,   *A__    ,   sampling_rate=A__    ,   **A__    )
      if text is not None:
       snake_case				=			self.tokenizer(A__    ,   **A__    )

      if text is None:
       return inputs

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







     def     UpperCamelCase			( self    ,   *A__    ,   **A__    ) ->	Optional[Any]:
      return self.tokenizer.batch_decode(*A__    ,   **A__    )







     def     UpperCamelCase			( self    ,   *A__    ,   **A__    ) ->	str:
      return self.tokenizer.decode(*A__    ,   **A__    )







     def     UpperCamelCase			( self    ,   A__    ,   A__="np"    ) ->	Optional[Any]:
      return self.tokenizer.get_prompt_ids(A__    ,   return_tensors=A__    )

