



from typing import Dict, List, Optional, Tuple, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    flip_channel_order,
    get_resize_output_image_size,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_torch_available, is_torch_tensor, is_vision_available, logging


if is_vision_available():
   import PIL

if is_torch_available():
   import torch


UpperCAmelCase_		 =					logging.get_logger(__name__)


class 	lowerCamelCase__	(       _A):



 """simple docstring"""

 a__					: Union[str, Any] =  ["pixel_values"]

 def __init__(    self					:					List[str]			,						__lowerCAmelCase					:					bool = True			,						__lowerCAmelCase					:					Dict[str, int] = None			,						__lowerCAmelCase					:					PILImageResampling = PILImageResampling.BILINEAR			,						__lowerCAmelCase					:					bool = True			,						__lowerCAmelCase					:					Union[int, float] = 1 / 2_55			,						__lowerCAmelCase					:					bool = True			,						__lowerCAmelCase					:					Dict[str, int] = None			,						__lowerCAmelCase					:					bool = True			,						**__lowerCAmelCase					:					List[Any]			,						)   ->	None:
    super().__init__(**__lowerCAmelCase      )
    _A      =       size if size is not None else {'''shortest_edge''': 2_24}
    _A      =       get_size_dict(__lowerCAmelCase			,						default_to_square=__lowerCAmelCase      )
    _A      =       crop_size if crop_size is not None else {'''height''': 2_56, '''width''': 2_56}
    _A      =       get_size_dict(__lowerCAmelCase			,						param_name='''crop_size'''      )

    _A      =       do_resize
    _A      =       size
    _A      =       resample
    _A      =       do_rescale
    _A      =       rescale_factor
    _A      =       do_center_crop
    _A      =       crop_size
    _A      =       do_flip_channel_order

 def     snake_case_      (    self					:					Any			,						__lowerCAmelCase					:					np.ndarray			,						__lowerCAmelCase					:					Dict[str, int]			,						__lowerCAmelCase					:					PILImageResampling = PIL.Image.BILINEAR			,						__lowerCAmelCase					:					Optional[Union[str, ChannelDimension]] = None			,						**__lowerCAmelCase					:					Optional[int]			,						)   ->	np.ndarray:
    _A      =       get_size_dict(__lowerCAmelCase			,						default_to_square=__lowerCAmelCase      )
    if "shortest_edge" not in size:
       raise ValueError(f'''The `size` dictionary must contain the key `shortest_edge`. Got {size.keys()}'''      )
    _A      =       get_resize_output_image_size(__lowerCAmelCase			,						size=size['''shortest_edge''']			,						default_to_square=__lowerCAmelCase      )
    return resize(__lowerCAmelCase			,						size=__lowerCAmelCase			,						resample=__lowerCAmelCase			,						data_format=__lowerCAmelCase			,						**__lowerCAmelCase      )

 def     snake_case_      (    self					:					Optional[int]			,						__lowerCAmelCase					:					np.ndarray			,						__lowerCAmelCase					:					Dict[str, int]			,						__lowerCAmelCase					:					Optional[Union[str, ChannelDimension]] = None			,						**__lowerCAmelCase					:					Dict			,						)   ->	np.ndarray:
    _A      =       get_size_dict(__lowerCAmelCase      )
    if "height" not in size or "width" not in size:
       raise ValueError(f'''The `size` dictionary must contain the keys `height` and `width`. Got {size.keys()}'''      )
    return center_crop(__lowerCAmelCase			,						size=(size['''height'''], size['''width'''])			,						data_format=__lowerCAmelCase			,						**__lowerCAmelCase      )

 def     snake_case_      (    self					:					Dict			,						__lowerCAmelCase					:					np.ndarray			,						__lowerCAmelCase					:					Union[int, float]			,						__lowerCAmelCase					:					Optional[Union[str, ChannelDimension]] = None			,						**__lowerCAmelCase					:					Any			,						)   ->	Optional[int]:
    return rescale(__lowerCAmelCase			,						scale=__lowerCAmelCase			,						data_format=__lowerCAmelCase			,						**__lowerCAmelCase      )

 def     snake_case_      (    self					:					Optional[int]			,						__lowerCAmelCase					:					np.ndarray			,						__lowerCAmelCase					:					Optional[Union[str, ChannelDimension]] = None      )   ->	np.ndarray:
    return flip_channel_order(__lowerCAmelCase			,						data_format=__lowerCAmelCase      )

 def     snake_case_      (    self					:					Optional[int]			,						__lowerCAmelCase					:					ImageInput			,						__lowerCAmelCase					:					bool = None			,						__lowerCAmelCase					:					Dict[str, int] = None			,						__lowerCAmelCase					:					PILImageResampling = None			,						__lowerCAmelCase					:					bool = None			,						__lowerCAmelCase					:					float = None			,						__lowerCAmelCase					:					bool = None			,						__lowerCAmelCase					:					Dict[str, int] = None			,						__lowerCAmelCase					:					bool = None			,						__lowerCAmelCase					:					Optional[Union[str, TensorType]] = None			,						__lowerCAmelCase					:					ChannelDimension = ChannelDimension.FIRST			,						**__lowerCAmelCase					:					Optional[int]			,						)   ->	PIL.Image.Image:
    _A      =       do_resize if do_resize is not None else self.do_resize
    _A      =       resample if resample is not None else self.resample
    _A      =       do_rescale if do_rescale is not None else self.do_rescale
    _A      =       rescale_factor if rescale_factor is not None else self.rescale_factor
    _A      =       do_center_crop if do_center_crop is not None else self.do_center_crop
    _A      =       (
        do_flip_channel_order if do_flip_channel_order is not None else self.do_flip_channel_order
    )

    _A      =       size if size is not None else self.size
    _A      =       get_size_dict(__lowerCAmelCase			,						default_to_square=__lowerCAmelCase      )
    _A      =       crop_size if crop_size is not None else self.crop_size
    _A      =       get_size_dict(__lowerCAmelCase			,						param_name='''crop_size'''      )

    _A      =       make_list_of_images(__lowerCAmelCase      )

    if not valid_images(__lowerCAmelCase      ):
       raise ValueError(
           '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
           '''torch.Tensor, tf.Tensor or jax.ndarray.'''      )

    if do_resize and size is None:
       raise ValueError('''Size must be specified if do_resize is True.'''      )

    if do_rescale and rescale_factor is None:
       raise ValueError('''Rescale factor must be specified if do_rescale is True.'''      )

    if do_center_crop and crop_size is None:
       raise ValueError('''Crop size must be specified if do_center_crop is True.'''      )

    # All transformations expect numpy arrays.
    _A      =       [to_numpy_array(__lowerCAmelCase      ) for image in images]

    if do_resize:
       _A      =       [self.resize(image=__lowerCAmelCase			,						size=__lowerCAmelCase			,						resample=__lowerCAmelCase      ) for image in images]

    if do_center_crop:
       _A      =       [self.center_crop(image=__lowerCAmelCase			,						size=__lowerCAmelCase      ) for image in images]

    if do_rescale:
       _A      =       [self.rescale(image=__lowerCAmelCase			,						scale=__lowerCAmelCase      ) for image in images]

    # the pretrained checkpoints assume images are BGR, not RGB
    if do_flip_channel_order:
       _A      =       [self.flip_channel_order(image=__lowerCAmelCase      ) for image in images]

    _A      =       [to_channel_dimension_format(__lowerCAmelCase			,						__lowerCAmelCase      ) for image in images]

    _A      =       {'''pixel_values''': images}
    return BatchFeature(data=__lowerCAmelCase			,						tensor_type=__lowerCAmelCase      )

 def     snake_case_      (    self					:					int			,						__lowerCAmelCase					:					Union[str, Any]			,						__lowerCAmelCase					:					List[Tuple] = None      )   ->	str:
    _A      =       outputs.logits

    # Resize logits and compute semantic segmentation maps
    if target_sizes is not None:
       if len(__lowerCAmelCase      ) != len(__lowerCAmelCase      ):
          raise ValueError(
              '''Make sure that you pass in as many target sizes as the batch dimension of the logits'''      )

       if is_torch_tensor(__lowerCAmelCase      ):
          _A      =       target_sizes.numpy()

       _A      =       []

       for idx in range(len(__lowerCAmelCase      )      ):
          _A      =       torch.nn.functional.interpolate(
              logits[idx].unsqueeze(dim=0      )			,						size=target_sizes[idx]			,						mode='''bilinear'''			,						align_corners=__lowerCAmelCase      )
          _A      =       resized_logits[0].argmax(dim=0      )
          semantic_segmentation.append(__lowerCAmelCase      )
    else:
       _A      =       logits.argmax(dim=1      )
       _A      =       [semantic_segmentation[i] for i in range(semantic_segmentation.shape[0]      )]

    return semantic_segmentation








import requests
from bsa import BeautifulSoup

def 	SCREAMING_SNAKE_CASE_							(	_snake_case	:str = "AAPL"				)  ->     str:
   _A      =       F'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}'''
   _A      =       BeautifulSoup(requests.get(_snake_case				).text	,   '''html.parser'''				)
   _A      =       '''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}')



