


from __future__ import annotations

import copy
import inspect
import json
import math
import os
import tempfile
import unittest
from importlib import import_module

import numpy as np

from transformers import ViTMAEConfig
from transformers.file_utils import cached_property, is_tf_available, is_vision_available
from transformers.testing_utils import require_tf, require_vision, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
  import tensorflow as tf

  from transformers import TFViTMAEForPreTraining, TFViTMAEModel


if is_vision_available():
  from PIL import Image

  from transformers import ViTImageProcessor



class    UpperCAmelCase_	:
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE=13 ,					__SCREAMING_SNAKE_CASE=30 ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=3 ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE=32 ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=4 ,					__SCREAMING_SNAKE_CASE=37 ,					__SCREAMING_SNAKE_CASE="gelu" ,					__SCREAMING_SNAKE_CASE=0.1 ,					__SCREAMING_SNAKE_CASE=0.1 ,					__SCREAMING_SNAKE_CASE=10 ,					__SCREAMING_SNAKE_CASE=0.02 ,					__SCREAMING_SNAKE_CASE=3 ,					__SCREAMING_SNAKE_CASE=0.6 ,					__SCREAMING_SNAKE_CASE=None ,					):




              """simple docstring"""




              UpperCamelCase    :	Tuple   	=		parent
              UpperCamelCase    :	Any   	=		batch_size
              UpperCamelCase    :	Optional[Any]   	=		image_size
              UpperCamelCase    :	Optional[int]   	=		patch_size
              UpperCamelCase    :	Union[str, Any]   	=		num_channels
              UpperCamelCase    :	List[Any]   	=		is_training
              UpperCamelCase    :	Tuple   	=		use_labels
              UpperCamelCase    :	Union[str, Any]   	=		hidden_size
              UpperCamelCase    :	List[Any]   	=		num_hidden_layers
              UpperCamelCase    :	Optional[Any]   	=		num_attention_heads
              UpperCamelCase    :	Dict   	=		intermediate_size
              UpperCamelCase    :	Optional[Any]   	=		hidden_act
              UpperCamelCase    :	List[str]   	=		hidden_dropout_prob
              UpperCamelCase    :	Any   	=		attention_probs_dropout_prob
              UpperCamelCase    :	int   	=		type_sequence_label_size
              UpperCamelCase    :	str   	=		initializer_range
              UpperCamelCase    :	Tuple   	=		mask_ratio
              UpperCamelCase    :	Dict   	=		scope

              # in ViTMAE, the expected sequence length = (num_patches + 1) * (1 - config.mask_ratio), rounded above
              # (we add 1 for the [CLS] token)
              UpperCamelCase    :	str   	=		(image_size // patch_size) ** 2
              UpperCamelCase    :	int   	=		int(math.ceil((1 - mask_ratio) * (num_patches + 1)						)						)






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	str   	=		floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]						)

              UpperCamelCase    :	Optional[int]   	=		None
              if self.use_labels:
                     UpperCamelCase    :	Dict   	=		ids_tensor([self.batch_size] ,					self.type_sequence_label_size						)

              UpperCamelCase    :	Any   	=		self.get_config()

              return config, pixel_values, labels






       def  _lowercase   (     self						):




              """simple docstring"""




              return ViTMAEConfig(
                  image_size=self.image_size ,					patch_size=self.patch_size ,					num_channels=self.num_channels ,					hidden_size=self.hidden_size ,					num_hidden_layers=self.num_hidden_layers ,					num_attention_heads=self.num_attention_heads ,					intermediate_size=self.intermediate_size ,					decoder_hidden_size=self.hidden_size ,					decoder_num_hidden_layers=self.num_hidden_layers ,					decoder_num_attention_heads=self.num_attention_heads ,					decoder_intermediate_size=self.intermediate_size ,					hidden_act=self.hidden_act ,					hidden_dropout_prob=self.hidden_dropout_prob ,					attention_probs_dropout_prob=self.attention_probs_dropout_prob ,					is_decoder=__SCREAMING_SNAKE_CASE ,					initializer_range=self.initializer_range ,					mask_ratio=self.mask_ratio ,					)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              UpperCamelCase    :	Dict   	=		TFViTMAEModel(config=__SCREAMING_SNAKE_CASE						)
              UpperCamelCase    :	str   	=		model(__SCREAMING_SNAKE_CASE ,					training=__SCREAMING_SNAKE_CASE						)
              self.parent.assertEqual(result.last_hidden_state.shape ,					(self.batch_size, self.seq_length, self.hidden_size)						)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              UpperCamelCase    :	Any   	=		TFViTMAEForPreTraining(__SCREAMING_SNAKE_CASE						)
              UpperCamelCase    :	str   	=		model(__SCREAMING_SNAKE_CASE ,					training=__SCREAMING_SNAKE_CASE						)
              # expected sequence length = num_patches
              UpperCamelCase    :	Tuple   	=		(self.image_size // self.patch_size) ** 2
              UpperCamelCase    :	str   	=		self.patch_size**2 * self.num_channels
              self.parent.assertEqual(result.logits.shape ,					(self.batch_size, num_patches, expected_num_channels)						)

              # test greyscale images
              UpperCamelCase    :	str   	=		1
              UpperCamelCase    :	List[str]   	=		TFViTMAEForPreTraining(__SCREAMING_SNAKE_CASE						)

              UpperCamelCase    :	Any   	=		floats_tensor([self.batch_size, 1, self.image_size, self.image_size]						)
              UpperCamelCase    :	List[Any]   	=		model(__SCREAMING_SNAKE_CASE ,					training=__SCREAMING_SNAKE_CASE						)
              UpperCamelCase    :	str   	=		self.patch_size**2
              self.parent.assertEqual(result.logits.shape ,					(self.batch_size, num_patches, expected_num_channels)						)






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	Tuple   	=		self.prepare_config_and_inputs()
              ((UpperCamelCase)	, (UpperCamelCase)	, (UpperCamelCase))    :	Tuple   	=		config_and_inputs
              UpperCamelCase    :	Dict   	=		{'''pixel_values''': pixel_values}
              return config, inputs_dict




@require_tf
class    UpperCAmelCase_	(							_a,     _a,     unittest.TestCase):
       '''simple docstring'''
       __UpperCamelCase      :     Optional[Any]							=					(TFViTMAEModel, TFViTMAEForPreTraining) if is_tf_available() else ()
       __UpperCamelCase      :     Tuple							=					{"feature-extraction": TFViTMAEModel} if is_tf_available() else {}

       __UpperCamelCase      :     Optional[Any]							=					False
       __UpperCamelCase      :     Tuple							=					False
       __UpperCamelCase      :     Any							=					False
       __UpperCamelCase      :     Union[str, Any]							=					False






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	List[str]   	=		TFViTMAEModelTester(self						)
              UpperCamelCase    :	Union[str, Any]   	=		ConfigTester(self ,					config_class=__SCREAMING_SNAKE_CASE ,					has_text_modality=__SCREAMING_SNAKE_CASE ,					hidden_size=37						)






       def  _lowercase   (     self						):




              """simple docstring"""




              self.config_tester.run_common_tests()






       @unittest.skip(reason='''ViTMAE does not use inputs_embeds'''						)
       def  _lowercase   (     self						):




              """simple docstring"""




              pass






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase	, UpperCamelCase    :	Tuple   	=		self.model_tester.prepare_config_and_inputs_for_common()

              for model_class in self.all_model_classes:
                     UpperCamelCase    :	Tuple   	=		model_class(__SCREAMING_SNAKE_CASE						)
                     self.assertIsInstance(model.get_input_embeddings() ,					(tf.keras.layers.Layer)						)
                     UpperCamelCase    :	Any   	=		model.get_output_embeddings()
                     self.assertTrue(x is None or isinstance(__SCREAMING_SNAKE_CASE ,					tf.keras.layers.Layer						)						)






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase	, UpperCamelCase    :	List[str]   	=		self.model_tester.prepare_config_and_inputs_for_common()

              for model_class in self.all_model_classes:
                     UpperCamelCase    :	Union[str, Any]   	=		model_class(__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Any   	=		inspect.signature(model.call						)
                     # signature.parameters is an OrderedDict => so arg_names order is deterministic
                     UpperCamelCase    :	Dict   	=		[*signature.parameters.keys()]

                     UpperCamelCase    :	Any   	=		['''pixel_values''']
                     self.assertListEqual(arg_names[:1] ,					__SCREAMING_SNAKE_CASE						)






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	List[str]   	=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE						)






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	List[Any]   	=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_pretraining(*__SCREAMING_SNAKE_CASE						)






       def  _lowercase   (     self						):




              """simple docstring"""




              np.random.seed(2						)

              UpperCamelCase	, UpperCamelCase    :	Dict   	=		self.model_tester.prepare_config_and_inputs_for_common()

              UpperCamelCase    :	str   	=		int((config.image_size // config.patch_size) ** 2						)
              UpperCamelCase    :	Optional[int]   	=		np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)

              for model_class in self.all_model_classes:
                     UpperCamelCase    :	int   	=		model_class(__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Any   	=		self._prepare_for_class(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)

                     UpperCamelCase    :	List[str]   	=		model(__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)

                     UpperCamelCase    :	Union[str, Any]   	=		copy.deepcopy(self._prepare_for_class(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)						)
                     UpperCamelCase    :	Optional[Any]   	=		model(**__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	int   	=		outputs_dict[0].numpy()
                     UpperCamelCase    :	Any   	=		outputs_keywords[0].numpy()

                     self.assertLess(np.sum(np.abs(output_dict - output_keywords						)						) ,					1e-6						)






       def  _lowercase   (     self						):




              """simple docstring"""




              np.random.seed(2						)

              UpperCamelCase	, UpperCamelCase    :	str   	=		self.model_tester.prepare_config_and_inputs_for_common()

              UpperCamelCase    :	Tuple   	=		int((config.image_size // config.patch_size) ** 2						)
              UpperCamelCase    :	List[Any]   	=		np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)

              def prepare_numpy_arrays(__SCREAMING_SNAKE_CASE						):
                     UpperCamelCase    :	Union[str, Any]   	=		{}
                     for k, v in inputs_dict.items():
                            if tf.is_tensor(__SCREAMING_SNAKE_CASE						):
                                   UpperCamelCase    :	Optional[int]   	=		v.numpy()
                            else:
                                   UpperCamelCase    :	str   	=		np.array(__SCREAMING_SNAKE_CASE						)

                     return inputs_np_dict

              for model_class in self.all_model_classes:
                     UpperCamelCase    :	Tuple   	=		model_class(__SCREAMING_SNAKE_CASE						)

                     UpperCamelCase    :	Union[str, Any]   	=		self._prepare_for_class(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Optional[Any]   	=		prepare_numpy_arrays(__SCREAMING_SNAKE_CASE						)

                     UpperCamelCase    :	List[Any]   	=		model(__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Optional[int]   	=		model(**__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)
                     self.assert_outputs_same(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              np.random.seed(2						)

              UpperCamelCase    :	List[str]   	=		int((tf_model.config.image_size // tf_model.config.patch_size) ** 2						)
              UpperCamelCase    :	Tuple   	=		np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)
              UpperCamelCase    :	Union[str, Any]   	=		tf.constant(__SCREAMING_SNAKE_CASE						)

              # Add `noise` argument.
              # PT inputs will be prepared in `super().check_pt_tf_models()` with this added `noise` argument
              UpperCamelCase    :	Optional[int]   	=		tf_noise

              super().check_pt_tf_models(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)






       def  _lowercase   (     self						):




              """simple docstring"""




              np.random.seed(2						)

              UpperCamelCase	, UpperCamelCase    :	Any   	=		self.model_tester.prepare_config_and_inputs_for_common()

              UpperCamelCase    :	List[str]   	=		{
                  module_member
                  for model_class in self.all_model_classes
                  for module in (import_module(model_class.__module__						),)
                  for module_member_name in dir(__SCREAMING_SNAKE_CASE						)
                  if module_member_name.endswith('''MainLayer'''						)
                  # This condition is required, since `modeling_tf_clip.py` has 3 classes whose names end with `MainLayer`.
                  and module_member_name[: -len('''MainLayer'''						)] == model_class.__name__[: -len('''Model'''						)]
                  for module_member in (getattr(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						),)
                  if isinstance(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)
                  and tf.keras.layers.Layer in module_member.__bases__
                  and getattr(__SCREAMING_SNAKE_CASE ,					'''_keras_serializable''' ,					__SCREAMING_SNAKE_CASE						)
              }

              UpperCamelCase    :	Union[str, Any]   	=		int((config.image_size // config.patch_size) ** 2						)
              UpperCamelCase    :	List[Any]   	=		np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)
              UpperCamelCase    :	Tuple   	=		tf.convert_to_tensor(__SCREAMING_SNAKE_CASE						)
              inputs_dict.update({'''noise''': noise}						)

              for main_layer_class in tf_main_layer_classes:
                     UpperCamelCase    :	Tuple   	=		main_layer_class(__SCREAMING_SNAKE_CASE						)

                     UpperCamelCase    :	Optional[Any]   	=		{
                         name: tf.keras.Input(tensor.shape[1:] ,					dtype=tensor.dtype						) for name, tensor in inputs_dict.items()
                     }

                     UpperCamelCase    :	Tuple   	=		tf.keras.Model(__SCREAMING_SNAKE_CASE ,					outputs=main_layer(__SCREAMING_SNAKE_CASE						)						)
                     UpperCamelCase    :	Optional[int]   	=		model(__SCREAMING_SNAKE_CASE						)

                     with tempfile.TemporaryDirectory() as tmpdirname:
                            UpperCamelCase    :	Any   	=		os.path.join(__SCREAMING_SNAKE_CASE ,					'''keras_model.h5'''						)
                            model.save(__SCREAMING_SNAKE_CASE						)
                            UpperCamelCase    :	Dict   	=		tf.keras.models.load_model(
                                __SCREAMING_SNAKE_CASE ,					custom_objects={main_layer_class.__name__: main_layer_class}						)
                            assert isinstance(__SCREAMING_SNAKE_CASE ,					tf.keras.Model						)
                            UpperCamelCase    :	Optional[Any]   	=		model(__SCREAMING_SNAKE_CASE						)
                            self.assert_outputs_same(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)






       @slow
       def  _lowercase   (     self						):




              """simple docstring"""




              np.random.seed(2						)

              UpperCamelCase	, UpperCamelCase    :	Optional[int]   	=		self.model_tester.prepare_config_and_inputs_for_common()

              UpperCamelCase    :	int   	=		int((config.image_size // config.patch_size) ** 2						)
              UpperCamelCase    :	int   	=		np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)

              for model_class in self.all_model_classes:
                     UpperCamelCase    :	int   	=		model_class(__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Union[str, Any]   	=		self._prepare_for_class(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Any   	=		model(__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)

                     if model_class.__name__ == "TFViTMAEModel":
                            UpperCamelCase    :	Optional[Any]   	=		outputs.last_hidden_state.numpy()
                            UpperCamelCase    :	Optional[int]   	=		0
                     else:
                            UpperCamelCase    :	str   	=		outputs.logits.numpy()
                            UpperCamelCase    :	Optional[int]   	=		0

                     with tempfile.TemporaryDirectory() as tmpdirname:
                            model.save_pretrained(__SCREAMING_SNAKE_CASE ,					saved_model=__SCREAMING_SNAKE_CASE						)
                            UpperCamelCase    :	Dict   	=		model_class.from_pretrained(__SCREAMING_SNAKE_CASE						)
                            UpperCamelCase    :	str   	=		model(__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)

                            if model_class.__name__ == "TFViTMAEModel":
                                   UpperCamelCase    :	List[str]   	=		after_outputs['''last_hidden_state'''].numpy()
                                   UpperCamelCase    :	Tuple   	=		0
                            else:
                                   UpperCamelCase    :	int   	=		after_outputs['''logits'''].numpy()
                                   UpperCamelCase    :	Union[str, Any]   	=		0

                            UpperCamelCase    :	Optional[Any]   	=		np.amax(np.abs(out_a - out_a						)						)
                            self.assertLessEqual(__SCREAMING_SNAKE_CASE ,					1e-5						)






       def  _lowercase   (     self						):




              """simple docstring"""




              np.random.seed(2						)

              UpperCamelCase	, UpperCamelCase    :	List[Any]   	=		self.model_tester.prepare_config_and_inputs_for_common()

              UpperCamelCase    :	Union[str, Any]   	=		int((config.image_size // config.patch_size) ** 2						)
              UpperCamelCase    :	Any   	=		np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)

              for model_class in self.all_model_classes:
                     UpperCamelCase    :	Optional[int]   	=		model_class(__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Optional[int]   	=		self._prepare_for_class(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)

                     UpperCamelCase    :	Any   	=		model(__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Dict   	=		model.get_config()
                     # make sure that returned config is jsonifiable, which is required by keras
                     json.dumps(__SCREAMING_SNAKE_CASE						)
                     UpperCamelCase    :	Dict   	=		model_class.from_config(model.get_config()						)
                     # make sure it also accepts a normal config
                     UpperCamelCase    :	str   	=		model_class.from_config(model.config						)
                     UpperCamelCase    :	Tuple   	=		new_model(__SCREAMING_SNAKE_CASE						)  # Build model
                     new_model.set_weights(model.get_weights()						)
                     UpperCamelCase    :	List[Any]   	=		new_model(__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)

                     self.assert_outputs_same(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)






       @unittest.skip(
           reason='''ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load
    to get deterministic results.'''						)
       def  _lowercase   (     self						):




              """simple docstring"""




              pass






       @unittest.skip(reason='''ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load'''						)
       def  _lowercase   (     self						):




              """simple docstring"""




              pass






       @slow
       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	List[str]   	=		TFViTMAEModel.from_pretrained('''google/vit-base-patch16-224'''						)
              self.assertIsNotNone(__SCREAMING_SNAKE_CASE						)




def      a	(							):






       """simple docstring"""





       UpperCamelCase    :	List[Any]   	=		Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''       )
       return image



@require_tf
@require_vision
class    UpperCAmelCase_	(							unittest.TestCase):
       '''simple docstring'''






       @cached_property
       def  _lowercase   (     self						):




              """simple docstring"""




              return ViTImageProcessor.from_pretrained('''facebook/vit-mae-base'''						) if is_vision_available() else None






       @slow
       def  _lowercase   (     self						):




              """simple docstring"""




              np.random.seed(2						)

              UpperCamelCase    :	List[Any]   	=		TFViTMAEForPreTraining.from_pretrained('''facebook/vit-mae-base'''						)

              UpperCamelCase    :	int   	=		self.default_image_processor
              UpperCamelCase    :	str   	=		prepare_img()
              UpperCamelCase    :	Dict   	=		image_processor(images=__SCREAMING_SNAKE_CASE ,					return_tensors='''tf'''						)

              # prepare a noise vector that will be also used for testing the TF model
              # (this way we can ensure that the PT and TF models operate on the same inputs)
              UpperCamelCase    :	Dict   	=		ViTMAEConfig()
              UpperCamelCase    :	str   	=		int((vit_mae_config.image_size // vit_mae_config.patch_size) ** 2						)
              UpperCamelCase    :	Dict   	=		np.random.uniform(size=(1, num_patches)						)

              # forward pass
              UpperCamelCase    :	Union[str, Any]   	=		model(**__SCREAMING_SNAKE_CASE ,					noise=__SCREAMING_SNAKE_CASE						)

              # verify the logits
              UpperCamelCase    :	str   	=		tf.convert_to_tensor([1, 196, 768]						)
              self.assertEqual(outputs.logits.shape ,					__SCREAMING_SNAKE_CASE						)

              UpperCamelCase    :	Optional[int]   	=		tf.convert_to_tensor(
                  [[-0.0_548, -1.7_023, -0.9_325], [0.3_721, -0.5_670, -0.2_233], [0.8_235, -1.3_878, -0.3_524]]						)

              tf.debugging.assert_near(outputs.logits[0, :3, :3] ,					__SCREAMING_SNAKE_CASE ,					atol=1e-4						)





import requests
from bsa import BeautifulSoup


def      a	(							SCREAMING_SNAKE_CASE_      :		str = "AAPL"       ):






       """simple docstring"""





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

