
'''simple docstring'''


import unittest

from transformers import is_torch_available, load_tool

from .test_tools_common import ToolTesterMixin


if is_torch_available():
	import torch




class     __snake_case			(    unittest.TestCase					,			_a	):




		def 	_snake_case	(  self					:Union[str, Any])					->			Dict:






								'''simple docstring'''






								UpperCamelCase_     :	Union[str, Any]					     =     load_tool("""speech-to-text""")
								self.tool.setup()




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






								'''simple docstring'''






								UpperCamelCase_     :	str					     =     self.tool(torch.ones(3_0_0_0))
								self.assertEqual(_A			,    """ you""")





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






								'''simple docstring'''






								UpperCamelCase_     :	Tuple					     =     self.tool(audio=torch.ones(3_0_0_0))
								self.assertEqual(_A			,    """ you""")







import os

from apache_beam.io.filesystems import FileSystems
from apache_beam.pipeline import Pipeline

from .logging import get_logger


lowerCamelCase   					=  2 << 2_0  # 2mb
lowerCamelCase   					=  get_logger(__name__)





class      snake_case_      (					_a				):


							"""simple docstring"""





							def 							A__	(			self				):
												__lowerCAmelCase       =				self._options.get_all_options().get('runner'				)
												return runner in [None, "DirectRunner", "PortableRunner"]


def 							__lowercase     (	UpperCAmelCase__		,       UpperCAmelCase__		,       UpperCAmelCase__=False   ):

					"""simple docstring"""






					__lowerCAmelCase       =				FileSystems
					if fs.exists(UpperCAmelCase__   ):
										if force_upload:
															logger.info(F"""Remote path already exist: {remote_file_path}. Overwriting it as force_upload=True."""   )
										else:
															logger.info(F"""Remote path already exist: {remote_file_path}. Skipping it as force_upload=False."""   )
															return
					with fs.create(UpperCAmelCase__   ) as remote_file:
										with open(UpperCAmelCase__		,       'rb'   ) as local_file:
															__lowerCAmelCase       =				local_file.read(UpperCAmelCase__   )
															while chunk:
																				remote_file.write(UpperCAmelCase__   )
																				__lowerCAmelCase       =				local_file.read(UpperCAmelCase__   )


def 							__lowercase     (	UpperCAmelCase__		,       UpperCAmelCase__		,       UpperCAmelCase__=False   ):

					"""simple docstring"""






					__lowerCAmelCase       =				FileSystems
					if os.path.exists(UpperCAmelCase__   ):
										if force_download:
															logger.info(F"""Local path already exist: {remote_file_path}. Overwriting it as force_upload=True."""   )
										else:
															logger.info(F"""Local path already exist: {remote_file_path}. Skipping it as force_upload=False."""   )
															return
					with fs.open(UpperCAmelCase__   ) as remote_file:
										with open(UpperCAmelCase__		,       'wb'   ) as local_file:
															__lowerCAmelCase       =				remote_file.read(UpperCAmelCase__   )
															while chunk:
																				local_file.write(UpperCAmelCase__   )
																				__lowerCAmelCase       =				remote_file.read(UpperCAmelCase__   )






