





import os

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

from .logging import get_logger


_lowerCamelCase       =	2 << 20  # 2mb
_lowerCamelCase       =	get_logger(__name__)




class      UpperCamelCase_				(   UpperCamelCase__			):


							def    _snake_case     (							self			:Optional[Any]						)      ->      List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self._options.get_all_options().get("""runner"""						)
									return runner in [None, "DirectRunner", "PortableRunner"]






def  SCREAMING_SNAKE_CASE__							(				UpperCamelCase__:							Optional[int]    ,      UpperCamelCase__:							Optional[int]    ,      UpperCamelCase__:							List[Any]=False			):
		SCREAMING_SNAKE_CASE__								=					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:
						SCREAMING_SNAKE_CASE__								=					local_file.read(UpperCamelCase__			)
						while chunk:
								remote_file.write(UpperCamelCase__			)
								SCREAMING_SNAKE_CASE__								=					local_file.read(UpperCamelCase__			)






def  SCREAMING_SNAKE_CASE__							(				UpperCamelCase__:							Optional[Any]    ,      UpperCamelCase__:							str    ,      UpperCamelCase__:							List[str]=False			):
		SCREAMING_SNAKE_CASE__								=					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:
						SCREAMING_SNAKE_CASE__								=					remote_file.read(UpperCamelCase__			)
						while chunk:
								local_file.write(UpperCamelCase__			)
								SCREAMING_SNAKE_CASE__								=					remote_file.read(UpperCamelCase__			)






import unittest

from transformers import is_torch_available, load_tool

from .test_tools_common import ToolTesterMixin


if is_torch_available():
	import torch




class      UpperCamelCase_				(   unittest.TestCase ,     UpperCamelCase__			):


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					load_tool("""speech-to-text"""						)
									self.tool.setup()


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.tool(torch.ones(3000						)						)
									self.assertEqual(__A							, """ you"""						)


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.tool(audio=torch.ones(3000						)						)
									self.assertEqual(__A							, """ you"""						)