'''simple docstring'''





import requests
from bsa import BeautifulSoup
def 						__A							(     UpperCAmelCase     ,UpperCAmelCase					)     ->			str:




						'''simple docstring'''
						_UpperCamelCase			:			Dict   			=						BeautifulSoup(requests.get(UpperCAmelCase     ,params=UpperCAmelCase					).content     ,"html.parser"					)
						_UpperCamelCase			:			Union[str, Any]   			=						soup.find("div"     ,attrs={"class": "gs_ri"}					)
						_UpperCamelCase			:			Optional[Any]   			=						div.find("div"     ,attrs={"class": "gs_fl"}					).find_all("a"					)
						return anchors[2].get_text()


if __name__ == "__main__":
			lowerCAmelCase_	:		Optional[int]			=     {
			    """title""": (
			        """Precisely geometry controlled microsupercapacitors for ultrahigh areal """
			        """capacitance, volumetric capacitance, and energy density"""
			    ),
			    """journal""": """Chem. Mater.""",
			    """volume""": 30,
			    """pages""": """3979-3990""",
			    """year""": 2018,
			    """hl""": """en""",
			}
			print(get_citation("""https://scholar.google.com/scholar_lookup""", params=params))



'''simple docstring'''





from __future__ import annotations

import inspect
import unittest

import numpy as np

from transformers import ResNetConfig
from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import cached_property, is_tf_available, is_vision_available

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 TFResNetForImageClassification, TFResNetModel
			from transformers.models.resnet.modeling_tf_resnet import TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
			from PIL import Image

			from transformers import AutoImageProcessor




class 		SCREAMING_SNAKE_CASE     :







				'''simple docstring'''





				def __init__(						self					:						Any       ,		lowercase__					:						Dict       ,		lowercase__					:						int=3       ,		lowercase__					:						Optional[Any]=32       ,		lowercase__					:						Optional[int]=3       ,		lowercase__					:						Any=10       ,		lowercase__					:						Tuple=[10, 20, 30, 40]       ,		lowercase__					:						List[str]=[1, 1, 2, 1]       ,		lowercase__					:						int=True       ,		lowercase__					:						int=True       ,		lowercase__					:						int="relu"       ,		lowercase__					:						List[str]=3       ,		lowercase__					:						Dict=None       ,		)							->List[Any]:


										'''simple docstring'''




										_UpperCamelCase			:			Tuple   			=						parent
										_UpperCamelCase			:			Tuple   			=						batch_size
										_UpperCamelCase			:			List[str]   			=						image_size
										_UpperCamelCase			:			Union[str, Any]   			=						num_channels
										_UpperCamelCase			:			List[str]   			=						embeddings_size
										_UpperCamelCase			:			Union[str, Any]   			=						hidden_sizes
										_UpperCamelCase			:			List[Any]   			=						depths
										_UpperCamelCase			:			Any   			=						is_training
										_UpperCamelCase			:			Union[str, Any]   			=						use_labels
										_UpperCamelCase			:			Tuple   			=						hidden_act
										_UpperCamelCase			:			int   			=						num_labels
										_UpperCamelCase			:			Union[str, Any]   			=						scope
										_UpperCamelCase			:			Union[str, Any]   			=						len(lowercase__					)





				def  snake_case__				(						self					:						int					)							->List[Any]:


										'''simple docstring'''




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

										_UpperCamelCase			:			int   			=						None
										if self.use_labels:
																_UpperCamelCase			:			Optional[int]   			=						ids_tensor([self.batch_size]       ,		self.num_labels					)

										_UpperCamelCase			:			List[str]   			=						self.get_config()

										return config, pixel_values, labels





				def  snake_case__				(						self					:						Any					)							->Dict:


										'''simple docstring'''




										return ResNetConfig(
										    num_channels=self.num_channels       ,		embeddings_size=self.embeddings_size       ,		hidden_sizes=self.hidden_sizes       ,		depths=self.depths       ,		hidden_act=self.hidden_act       ,		num_labels=self.num_labels       ,		image_size=self.image_size       ,		)





				def  snake_case__				(						self					:						Tuple       ,		lowercase__					:						Tuple       ,		lowercase__					:						Any       ,		lowercase__					:						Any					)							->Any:


										'''simple docstring'''




										_UpperCamelCase			:			Any   			=						TFResNetModel(config=lowercase__					)
										_UpperCamelCase			:			Dict   			=						model(lowercase__					)
										# expected last hidden states: B, C, H // 32, W // 32
										self.parent.assertEqual(
										    result.last_hidden_state.shape       ,		(self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32)       ,		)





				def  snake_case__				(						self					:						int       ,		lowercase__					:						str       ,		lowercase__					:						int       ,		lowercase__					:						Any					)							->Optional[int]:


										'''simple docstring'''




										_UpperCamelCase			:			str   			=						self.num_labels
										_UpperCamelCase			:			List[str]   			=						TFResNetForImageClassification(lowercase__					)
										_UpperCamelCase			:			Tuple   			=						model(lowercase__       ,		labels=lowercase__					)
										self.parent.assertEqual(result.logits.shape       ,		(self.batch_size, self.num_labels)					)







				def  snake_case__				(						self					:						int					)							->List[Any]:


										'''simple docstring'''




										_UpperCamelCase			:			List[str]   			=						self.prepare_config_and_inputs()
										_UpperCamelCase			,       _UpperCamelCase			,       _UpperCamelCase			:			List[str]   			=						config_and_inputs
										_UpperCamelCase			:			List[str]   			=						{"pixel_values": pixel_values}
										return config, inputs_dict





@require_tf
class 		SCREAMING_SNAKE_CASE     (					SCREAMING_SNAKE_CASE   , SCREAMING_SNAKE_CASE   , unittest.TestCase	):







				'''simple docstring'''
				UpperCAmelCase__							=							(TFResNetModel, TFResNetForImageClassification) if is_tf_available() else ()
				UpperCAmelCase__							=							(
				    {'''feature-extraction''': TFResNetModel, '''image-classification''': TFResNetForImageClassification}
				    if is_tf_available()
				    else {}
				)

				UpperCAmelCase__							=							False
				UpperCAmelCase__							=							False
				UpperCAmelCase__							=							False
				UpperCAmelCase__							=							False
				UpperCAmelCase__							=							False





				def  snake_case__				(						self					:						int					)							->Any:


										'''simple docstring'''




										_UpperCamelCase			:			int   			=						TFResNetModelTester(self					)
										_UpperCamelCase			:			Union[str, Any]   			=						ConfigTester(self       ,		config_class=lowercase__       ,		has_text_modality=lowercase__					)





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


										'''simple docstring'''




										self.create_and_test_config_common_properties()
										self.config_tester.create_and_test_config_to_json_string()
										self.config_tester.create_and_test_config_to_json_file()
										self.config_tester.create_and_test_config_from_and_save_pretrained()
										self.config_tester.create_and_test_config_with_num_labels()
										self.config_tester.check_config_can_be_init_without_params()
										self.config_tester.check_config_arguments_init()





				def  snake_case__				(						self					:						Dict					)							->List[str]:


										'''simple docstring'''




										return





				@unittest.skip(reason="ResNet does not use inputs_embeds"					)
				def  snake_case__				(						self					:						Union[str, Any]					)							->str:


										'''simple docstring'''




										pass





				@unittest.skip(reason="ResNet does not support input and output embeddings"					)
				def  snake_case__				(						self					:						Optional[Any]					)							->Union[str, Any]:


										'''simple docstring'''




										pass





				def  snake_case__				(						self					:						Tuple					)							->Optional[int]:


										'''simple docstring'''




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

										for model_class in self.all_model_classes:
																_UpperCamelCase			:			Dict   			=						model_class(lowercase__					)
																_UpperCamelCase			:			Optional[Any]   			=						inspect.signature(model.call					)
																# signature.parameters is an OrderedDict => so arg_names order is deterministic
																_UpperCamelCase			:			Dict   			=						[*signature.parameters.keys()]

																_UpperCamelCase			:			Union[str, Any]   			=						["pixel_values"]
																self.assertListEqual(arg_names[:1]       ,		lowercase__					)





				def  snake_case__				(						self					:						Optional[int]					)							->Optional[Any]:


										'''simple docstring'''




										_UpperCamelCase			:			Dict   			=						self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*lowercase__					)





				def  snake_case__				(						self					:						List[str]					)							->str:


										'''simple docstring'''




										def check_hidden_states_output(lowercase__					:						Union[str, Any]       ,		lowercase__					:						List[Any]       ,		lowercase__					:						Optional[int]					):
																_UpperCamelCase			:			Union[str, Any]   			=						model_class(lowercase__					)
																_UpperCamelCase			:			Optional[int]   			=						model(**self._prepare_for_class(lowercase__       ,		lowercase__					)					)

																_UpperCamelCase			:			List[Any]   			=						outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

																_UpperCamelCase			:			Union[str, Any]   			=						self.model_tester.num_stages
																self.assertEqual(len(lowercase__					)       ,		expected_num_stages + 1					)

																# ResNet's feature maps are of shape (batch_size, num_channels, height, width)
																self.assertListEqual(
																    list(hidden_states[0].shape[-2:]					)       ,		[self.model_tester.image_size // 4, self.model_tester.image_size // 4]       ,		)

										_UpperCamelCase			,       _UpperCamelCase			:			Dict   			=						self.model_tester.prepare_config_and_inputs_for_common()
										_UpperCamelCase			:			Any   			=						["basic", "bottleneck"]
										for model_class in self.all_model_classes:
																for layer_type in layers_type:
																						_UpperCamelCase			:			Optional[Any]   			=						layer_type
																						_UpperCamelCase			:			str   			=						True
																						check_hidden_states_output(lowercase__       ,		lowercase__       ,		lowercase__					)

																						# check that output_hidden_states also work using config
																						del inputs_dict["output_hidden_states"]
																						_UpperCamelCase			:			int   			=						True

																						check_hidden_states_output(lowercase__       ,		lowercase__       ,		lowercase__					)





				def  snake_case__				(						self					:						Optional[int]					)							->str:


										'''simple docstring'''




										_UpperCamelCase			:			List[Any]   			=						self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_image_classification(*lowercase__					)







				@slow
				def  snake_case__				(						self					:						List[Any]					)							->Dict:


										'''simple docstring'''




										for model_name in TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																_UpperCamelCase			:			Optional[Any]   			=						TFResNetModel.from_pretrained(lowercase__					)
																self.assertIsNotNone(lowercase__					)





def 						__A							(     )     ->			Dict:




						'''simple docstring'''
						_UpperCamelCase			:			Optional[int]   			=						Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"					)
						return image






@require_tf
@require_vision
class 		SCREAMING_SNAKE_CASE     (					unittest.TestCase	):







				'''simple docstring'''





				@cached_property
				def  snake_case__				(						self					:						List[Any]					)							->Union[str, Any]:


										'''simple docstring'''




										return (
										    AutoImageProcessor.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]					)
										    if is_vision_available()
										    else None
										)







				@slow
				def  snake_case__				(						self					:						Optional[int]					)							->List[str]:


										'''simple docstring'''




										_UpperCamelCase			:			Dict   			=						TFResNetForImageClassification.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]					)

										_UpperCamelCase			:			Optional[int]   			=						self.default_image_processor
										_UpperCamelCase			:			Optional[Any]   			=						prepare_img()
										_UpperCamelCase			:			str   			=						image_processor(images=lowercase__       ,		return_tensors="tf"					)

										# forward pass
										_UpperCamelCase			:			List[str]   			=						model(**lowercase__					)

										# verify the logits
										_UpperCamelCase			:			Optional[Any]   			=						tf.TensorShape((1, 1_000)					)
										self.assertEqual(outputs.logits.shape       ,		lowercase__					)

										_UpperCamelCase			:			Optional[int]   			=						tf.constant([-1_1.1_0_6_9, -9.7_8_7_7, -8.3_7_7_7]					)

										self.assertTrue(np.allclose(outputs.logits[0, :3].numpy()       ,		lowercase__       ,		atol=1e-4					)					)


