






"""simple docstring"""







import os
from argparse import ArgumentParser
from typing import List

import torch.utils.data

from datasets import Dataset, IterableDataset
from datasets.distributed import split_dataset_by_node


_lowerCAmelCase            =	4
_lowerCAmelCase            =	3


class      UpperCamelCase		(__snake_case     ):
						pass


def      UpperCamelCase       ( _A )     ->       Optional[int]:
				for shard in shards:
								for i in range(_A ):
												yield {"i": i, "shard": shard}


def      UpperCamelCase       ( )     ->       List[Any]:
				lowercase    :      List[str]       = int(os.environ["""RANK"""] )
				lowercase    :      str       = int(os.environ["""WORLD_SIZE"""] )

				lowercase    :      List[Any]       = ArgumentParser()
				parser.add_argument("""--streaming"""  ,				type=_A )
				parser.add_argument("""--local_rank"""  ,				type=_A )
				parser.add_argument("""--num_workers"""  ,				type=_A  ,				default=0 )
				lowercase    :      Union[str, Any]       = parser.parse_args()
				lowercase    :      Any       = args.streaming
				lowercase    :      Tuple       = args.num_workers

				lowercase    :      List[Any]       = {"""shards""": [F"""shard_{shard_idx}""" for shard_idx in range(_A )]}
				lowercase    :      Tuple       = IterableDataset.from_generator(_A  ,				gen_kwargs=_A )
				if not streaming:
								lowercase    :      Any       = Dataset.from_list(list(_A ) )

				lowercase    :      Any       = split_dataset_by_node(_A  ,				rank=_A  ,				world_size=_A )
				lowercase    :      Dict       = torch.utils.data.DataLoader(_A  ,				num_workers=_A )

				lowercase    :      Tuple       = NUM_SHARDS * NUM_ITEMS_PER_SHARD
				lowercase    :      str       = full_size // world_size
				expected_local_size += int(rank < (full_size % world_size) )

				lowercase    :      Optional[Any]       = sum(1 for _ in dataloader )
				if local_size != expected_local_size:
								raise FailedTestError(F"""local_size {local_size} != expected_local_size {expected_local_size}""" )


if __name__ == "__main__":
				main()








"""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}')
