from dataclasses import dataclass, field
from typing import Tuple

from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends
from .benchmark_args_utils import BenchmarkArguments


if is_torch_available():
				import torch

if is_torch_tpu_available(check_device=False):
				import torch_xla.core.xla_model as xm


A						=			logging.get_logger(__name__)





@dataclass
class     lowerCAmelCase__     (				__snake_case			):


		'''simple docstring'''






		lowerCAmelCase_     =   [
		    """no_inference""",
		    """no_cuda""",
		    """no_tpu""",
		    """no_speed""",
		    """no_memory""",
		    """no_env_print""",
		    """no_multi_process""",
		]
		def __init__(       self     :     Union[str, Any]     ,  **snake_case__     :     int		)      ->	Any:
				for deprecated_arg in self.deprecated_args:
						if deprecated_arg in kwargs:
								_lowerCamelCase				   =  deprecated_arg[3:]
								setattr(self     ,  snake_case__     ,  not kwargs.pop(snake_case__		)		)
								logger.warning(
								    f"""{deprecated_arg} is depreciated. Please use --no_{positive_arg} or"""
								    f""" {positive_arg}={kwargs[positive_arg]}"""		)

				_lowerCamelCase				   =  kwargs.pop('torchscript'     ,  self.torchscript		)
				_lowerCamelCase				   =  kwargs.pop('torch_xla_tpu_print_metrics'     ,  self.torch_xla_tpu_print_metrics		)
				_lowerCamelCase				   =  kwargs.pop('fp16_opt_level'     ,  self.fpaa_opt_level		)
				super().__init__(**snake_case__		)

		lowerCAmelCase_     =   field(default=__snake_case     ,metadata={'help': 'Trace the models using torchscript'}			)
		lowerCAmelCase_     =   field(default=__snake_case     ,metadata={'help': 'Print Xla/PyTorch tpu metrics'}			)
		lowerCAmelCase_     =   field(
		    default='O1'     ,metadata={
		        'help': (
		            'For fp16: Apex AMP optimization level selected in [\'O0\', \'O1\', \'O2\', and \'O3\']. '
		            'See details at https://nvidia.github.io/apex/amp.html'
		        )
		    }     ,)
		@cached_property
		def   _snake_case       (       self     :     Optional[int]		)      ->	Tuple["torch.device", int]:
				requires_backends(self     ,  ['torch']		)
				logger.info('PyTorch: setting up devices'		)
				if not self.cuda:
						_lowerCamelCase				   =  torch.device('cpu'		)
						_lowerCamelCase				   =  0
				elif is_torch_tpu_available():
						_lowerCamelCase				   =  xm.xla_device()
						_lowerCamelCase				   =  0
				else:
						_lowerCamelCase				   =  torch.device('cuda' if torch.cuda.is_available() else 'cpu'		)
						_lowerCamelCase				   =  torch.cuda.device_count()
				return device, n_gpu
		@property
		def   _snake_case       (       self     :     Optional[int]		)      ->	Union[str, Any]:
				return is_torch_tpu_available() and self.tpu
		@property
		def   _snake_case       (       self     :     Optional[int]		)      ->	int:
				requires_backends(self     ,  ['torch']		)
				# TODO(PVP): currently only single GPU is supported
				return torch.cuda.current_device()
		@property
		def   _snake_case       (       self     :     Optional[int]		)      ->	"torch.device":
				requires_backends(self     ,  ['torch']		)
				return self._setup_devices[0]
		@property
		def   _snake_case       (       self     :     Optional[Any]		)      ->	str:
				requires_backends(self     ,  ['torch']		)
				return self._setup_devices[1]



		@property
		def   _snake_case       (       self     :     int		)      ->	List[str]:
				return self.n_gpu > 0







"""simple docstring"""







import requests
from bsa import BeautifulSoup


def      UpperCamelCase       ( _A = "AAPL" )     ->       str:
				lowercase    :      Optional[Any]       = F"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}"""
				lowercase    :      str       = BeautifulSoup(requests.get(_A ).text  ,				"""html.parser""" )
				lowercase    :      int       = """My(6px) Pos(r) smartphone_Mt(6px)"""
				return soup.find("""div"""  ,				class_=class_ ).find("""span""" ).text


if __name__ == "__main__":
				for symbol in "AAPL AMZN IBM GOOG MSFT ORCL".split():
								print(F'Current {symbol:<4} stock price is {stock_price(symbol):>8}')
