






import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin



class       __UpperCAmelCase		(_UpperCAmelCase    ):
			__snake_case				:      Optional[Any] 						=							"Speech2TextFeatureExtractor"
			__snake_case				:      Dict 						=							"Speech2TextTokenizer"







			def __init__(	self:  Dict      ,	UpperCAmelCase_:  str      ,	UpperCAmelCase_:  List[Any]     ):







									'''simple docstring'''




									super().__init__(UpperCAmelCase_      ,	UpperCAmelCase_     )
									_SCREAMING_SNAKE_CASE	      =  self.feature_extractor
									_SCREAMING_SNAKE_CASE	      =  False







			def __call__(	self:  Dict      ,	*UpperCAmelCase_:  int      ,	**UpperCAmelCase_:  List[str]     ):







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

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







			def 							UpperCamelCase      (	self:  List[str]      ,	*UpperCAmelCase_:  Union[str, Any]      ,	**UpperCAmelCase_:  int     ):







									'''simple docstring'''




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







			def 							UpperCamelCase      (	self:  str      ,	*UpperCAmelCase_:  List[str]      ,	**UpperCAmelCase_:  List[str]     ):







									'''simple docstring'''




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







			@contextmanager
			def 							UpperCamelCase      (	self:  Dict     ):







									'''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	      =  True
									_SCREAMING_SNAKE_CASE	      =  self.tokenizer
									yield
									_SCREAMING_SNAKE_CASE	      =  self.feature_extractor
									_SCREAMING_SNAKE_CASE	      =  False





'''simple docstring'''

# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from argparse import ArgumentParser

from accelerate.commands.config import get_config_parser
from accelerate.commands.env import env_command_parser
from accelerate.commands.launch import launch_command_parser
from accelerate.commands.test import test_command_parser
from accelerate.commands.tpu import tpu_command_parser





def __snake_case					(      ):
 lowerCamelCase_      =  ArgumentParser("Accelerate CLI tool"					,				usage="accelerate <command> [<args>]"					,				allow_abbrev=UpperCAmelCase_		)
 lowerCamelCase_      =  parser.add_subparsers(help="accelerate command helpers"		)

 # Register commands
 get_config_parser(subparsers=UpperCAmelCase_		)
 env_command_parser(subparsers=UpperCAmelCase_		)
 launch_command_parser(subparsers=UpperCAmelCase_		)
 tpu_command_parser(subparsers=UpperCAmelCase_		)
 test_command_parser(subparsers=UpperCAmelCase_		)

 # Let's go
 lowerCamelCase_      =  parser.parse_args()

 if not hasattr(UpperCAmelCase_					,				"func"		):
  parser.print_help()
  exit(1		)

 # Run
 args.func(UpperCAmelCase_		)


if __name__ == "__main__":
     main()



