


'''simple docstring'''

from __future__ import annotations

import unittest

from transformers import DistilBertConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

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


if is_tf_available():
	import tensorflow as tf

	from transformers.models.distilbert.modeling_tf_distilbert import (
	    TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
	    TFDistilBertForMaskedLM,
	    TFDistilBertForMultipleChoice,
	    TFDistilBertForQuestionAnswering,
	    TFDistilBertForSequenceClassification,
	    TFDistilBertForTokenClassification,
	    TFDistilBertModel,
	)


class       a__				:







				"""simple docstring"""



				def __init__(self       ,			__lowercase       ,			):
										__lowerCAmelCase							       =				parent
										__lowerCAmelCase							       =				13
										__lowerCAmelCase							       =				7
										__lowerCAmelCase							       =				True
										__lowerCAmelCase							       =				True
										__lowerCAmelCase							       =				False
										__lowerCAmelCase							       =				True
										__lowerCAmelCase							       =				99
										__lowerCAmelCase							       =				32
										__lowerCAmelCase							       =				2
										__lowerCAmelCase							       =				4
										__lowerCAmelCase							       =				37
										__lowerCAmelCase							       =				'''gelu'''
										__lowerCAmelCase							       =				0.1
										__lowerCAmelCase							       =				0.1
										__lowerCAmelCase							       =				5_12
										__lowerCAmelCase							       =				16
										__lowerCAmelCase							       =				2
										__lowerCAmelCase							       =				0.0_2
										__lowerCAmelCase							       =				3
										__lowerCAmelCase							       =				4
										__lowerCAmelCase							       =				None




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				ids_tensor([self.batch_size, self.seq_length]       ,			self.vocab_size		)

										__lowerCAmelCase							       =				None
										if self.use_input_mask:
																__lowerCAmelCase							       =				random_attention_mask([self.batch_size, self.seq_length]		)

										__lowerCAmelCase							       =				None
										__lowerCAmelCase							       =				None
										__lowerCAmelCase							       =				None
										if self.use_labels:
																__lowerCAmelCase							       =				ids_tensor([self.batch_size]       ,			self.type_sequence_label_size		)
																__lowerCAmelCase							       =				ids_tensor([self.batch_size, self.seq_length]       ,			self.num_labels		)
																__lowerCAmelCase							       =				ids_tensor([self.batch_size]       ,			self.num_choices		)

										__lowerCAmelCase							       =				DistilBertConfig(
										    vocab_size=self.vocab_size       ,			dim=self.hidden_size       ,			n_layers=self.num_hidden_layers       ,			n_heads=self.num_attention_heads       ,			hidden_dim=self.intermediate_size       ,			hidden_act=self.hidden_act       ,			dropout=self.hidden_dropout_prob       ,			attention_dropout=self.attention_probs_dropout_prob       ,			max_position_embeddings=self.max_position_embeddings       ,			initializer_range=self.initializer_range       ,			)

										return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels




				def 					_snake_case  (self       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase		):
										__lowerCAmelCase							       =				TFDistilBertModel(config=__lowercase		)
										__lowerCAmelCase							       =				{'''input_ids''': input_ids, '''attention_mask''': input_mask}

										__lowerCAmelCase							       =				model(__lowercase		)

										__lowerCAmelCase							       =				[input_ids, input_mask]

										__lowerCAmelCase							       =				model(__lowercase		)

										self.parent.assertEqual(result.last_hidden_state.shape       ,			(self.batch_size, self.seq_length, self.hidden_size)		)




				def 					_snake_case  (self       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase		):
										__lowerCAmelCase							       =				TFDistilBertForMaskedLM(config=__lowercase		)
										__lowerCAmelCase							       =				{'''input_ids''': input_ids, '''attention_mask''': input_mask}
										__lowerCAmelCase							       =				model(__lowercase		)
										self.parent.assertEqual(result.logits.shape       ,			(self.batch_size, self.seq_length, self.vocab_size)		)




				def 					_snake_case  (self       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase		):
										__lowerCAmelCase							       =				TFDistilBertForQuestionAnswering(config=__lowercase		)
										__lowerCAmelCase							       =				{
										    '''input_ids''': input_ids,
										    '''attention_mask''': input_mask,
										}
										__lowerCAmelCase							       =				model(__lowercase		)
										self.parent.assertEqual(result.start_logits.shape       ,			(self.batch_size, self.seq_length)		)
										self.parent.assertEqual(result.end_logits.shape       ,			(self.batch_size, self.seq_length)		)




				def 					_snake_case  (self       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase		):
										__lowerCAmelCase							       =				self.num_labels
										__lowerCAmelCase							       =				TFDistilBertForSequenceClassification(__lowercase		)
										__lowerCAmelCase							       =				{'''input_ids''': input_ids, '''attention_mask''': input_mask}
										__lowerCAmelCase							       =				model(__lowercase		)
										self.parent.assertEqual(result.logits.shape       ,			(self.batch_size, self.num_labels)		)




				def 					_snake_case  (self       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase		):
										__lowerCAmelCase							       =				self.num_choices
										__lowerCAmelCase							       =				TFDistilBertForMultipleChoice(__lowercase		)
										__lowerCAmelCase							       =				tf.tile(tf.expand_dims(__lowercase       ,			1		)       ,			(1, self.num_choices, 1)		)
										__lowerCAmelCase							       =				tf.tile(tf.expand_dims(__lowercase       ,			1		)       ,			(1, self.num_choices, 1)		)
										__lowerCAmelCase							       =				{
										    '''input_ids''': multiple_choice_inputs_ids,
										    '''attention_mask''': multiple_choice_input_mask,
										}
										__lowerCAmelCase							       =				model(__lowercase		)
										self.parent.assertEqual(result.logits.shape       ,			(self.batch_size, self.num_choices)		)




				def 					_snake_case  (self       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase       ,			__lowercase		):
										__lowerCAmelCase							       =				self.num_labels
										__lowerCAmelCase							       =				TFDistilBertForTokenClassification(__lowercase		)
										__lowerCAmelCase							       =				{'''input_ids''': input_ids, '''attention_mask''': input_mask}
										__lowerCAmelCase							       =				model(__lowercase		)
										self.parent.assertEqual(result.logits.shape       ,			(self.batch_size, self.seq_length, self.num_labels)		)




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				self.prepare_config_and_inputs()
										((__lowerCAmelCase)       ,					(__lowerCAmelCase)       ,					(__lowerCAmelCase)       ,					(__lowerCAmelCase)       ,					(__lowerCAmelCase)       ,					(__lowerCAmelCase))							       =				config_and_inputs
										__lowerCAmelCase							       =				{'''input_ids''': input_ids, '''attention_mask''': input_mask}
										return config, inputs_dict


@require_tf
class       a__				( __A							,						__A							,						unittest.TestCase      ):







				"""simple docstring"""



				__UpperCamelCase    :		Any	=	(
				    (
				        TFDistilBertModel,
				        TFDistilBertForMaskedLM,
				        TFDistilBertForQuestionAnswering,
				        TFDistilBertForSequenceClassification,
				        TFDistilBertForTokenClassification,
				        TFDistilBertForMultipleChoice,
				    )
				    if is_tf_available()
				    else None
				)
				__UpperCamelCase    :		Tuple	=	(
				    {
				        'feature-extraction': TFDistilBertModel,
				        'fill-mask': TFDistilBertForMaskedLM,
				        'question-answering': TFDistilBertForQuestionAnswering,
				        'text-classification': TFDistilBertForSequenceClassification,
				        'token-classification': TFDistilBertForTokenClassification,
				        'zero-shot': TFDistilBertForSequenceClassification,
				    }
				    if is_tf_available()
				    else {}
				)
				__UpperCamelCase    :		Union[str, Any]	=	False
				__UpperCamelCase    :		str	=	False




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				TFDistilBertModelTester(self		)
										__lowerCAmelCase							       =				ConfigTester(self       ,			config_class=__lowercase       ,			dim=37		)




				def 					_snake_case  (self		):
										self.config_tester.run_common_tests()




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_distilbert_model(*__lowercase		)




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_distilbert_for_masked_lm(*__lowercase		)




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_distilbert_for_question_answering(*__lowercase		)




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_distilbert_for_sequence_classification(*__lowercase		)




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_distilbert_for_multiple_choice(*__lowercase		)




				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_distilbert_for_token_classification(*__lowercase		)




				@slow
				def 					_snake_case  (self		):
										for model_name in list(TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]		):
																__lowerCAmelCase							       =				TFDistilBertModel.from_pretrained(__lowercase		)
																self.assertIsNotNone(__lowercase		)


@require_tf
class       a__				( unittest.TestCase      ):







				"""simple docstring"""



				@slow
				def 					_snake_case  (self		):
										__lowerCAmelCase							       =				TFDistilBertModel.from_pretrained('''distilbert-base-uncased'''		)
										__lowerCAmelCase							       =				tf.constant([[0, 1, 2, 3, 4, 5]]		)
										__lowerCAmelCase							       =				model(__lowercase		)[0]

										__lowerCAmelCase							       =				[1, 6, 7_68]
										self.assertEqual(output.shape       ,			__lowercase		)

										__lowerCAmelCase							       =				tf.constant(
										    [
										        [
										            [0.1_9_2_6_1_8_8_5, -0.1_3_7_3_2_9_5_5, 0.4_1_1_9_7_9_9],
										            [0.2_2_1_5_0_1_5_6, -0.0_7_4_2_2_6_6_1, 0.3_9_0_3_7_2_0_4],
										            [0.2_2_7_5_6_0_1_8, -0.0_8_9_6_4_1_4, 0.3_7_0_1_4_6_7],
										        ]
										    ]		)
										tf.debugging.assert_near(output[:, :3, :3]       ,			__lowercase       ,			atol=1e-4		)





'''simple docstring'''

import requests
from bsa import BeautifulSoup

def 							__magic_name__(						lowerCamelCase,				lowerCamelCase):
						__lowerCAmelCase							       =				BeautifulSoup(requests.get(lowerCamelCase,				params=lowerCamelCase).content,				'''html.parser''')
						__lowerCAmelCase							       =				soup.find('''div''',				attrs={'''class''': '''gs_ri'''})
						__lowerCAmelCase							       =				div.find('''div''',				attrs={'''class''': '''gs_fl'''}).find_all('''a''')
						return anchors[2].get_text()


if __name__ == "__main__":
	_UpperCAmelCase				: Union[str, Any]							    =				{
	    """title""": (
	        """Precisely geometry controlled microsupercapacitors for ultrahigh areal """
	        """capacitance, volumetric capacitance, and energy density"""
	    ),
	    """journal""": """Chem. Mater.""",
	    """volume""": 3_0,
	    """pages""": """3979-3990""",
	    """year""": 2_0_1_8,
	    """hl""": """en""",
	}
	print(get_citation("""https://scholar.google.com/scholar_lookup""", params=params))

