





import unittest

from transformers import MPNetConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch

						from transformers import (
						    MPNetForMaskedLM,
						    MPNetForMultipleChoice,
						    MPNetForQuestionAnswering,
						    MPNetForSequenceClassification,
						    MPNetForTokenClassification,
						    MPNetModel,
						)
class SCREAMING_SNAKE_CASE_						:






						def __init__(      self      :      str		,   _A      :      Dict		,   _A      :      Dict=13		,   _A      :      Any=7		,   _A      :      List[str]=True		,   _A      :      List[str]=True		,   _A      :      Tuple=False		,   _A      :      List[str]=True		,   _A      :      Tuple=99		,   _A      :      Optional[int]=64		,   _A      :      Tuple=5		,   _A      :      List[str]=4		,   _A      :      Optional[int]=64		,   _A      :      Optional[Any]="gelu"		,   _A      :      Optional[int]=0.1		,   _A      :      int=0.1		,   _A      :      Optional[Any]=512		,   _A      :      List[Any]=16		,   _A      :      Dict=2		,   _A      :      Optional[int]=0.0_2		,   _A      :      Optional[int]=3		,   _A      :      Optional[Any]=4		,   _A      :      Optional[int]=None		,   )							->    List[str]:







							"""simple docstring"""


							snake_case_		:			int											=	parent
							snake_case_		:			List[Any]											=	batch_size
							snake_case_		:			str											=	seq_length
							snake_case_		:			Any											=	is_training
							snake_case_		:			int											=	use_input_mask
							snake_case_		:			Optional[Any]											=	use_token_type_ids
							snake_case_		:			List[Any]											=	use_labels
							snake_case_		:			Any											=	vocab_size
							snake_case_		:			Tuple											=	hidden_size
							snake_case_		:			List[Any]											=	num_hidden_layers
							snake_case_		:			int											=	num_attention_heads
							snake_case_		:			Tuple											=	intermediate_size
							snake_case_		:			List[Any]											=	hidden_act
							snake_case_		:			List[Any]											=	hidden_dropout_prob
							snake_case_		:			List[Any]											=	attention_probs_dropout_prob
							snake_case_		:			int											=	max_position_embeddings
							snake_case_		:			Tuple											=	type_vocab_size
							snake_case_		:			int											=	type_sequence_label_size
							snake_case_		:			List[Any]											=	initializer_range
							snake_case_		:			List[str]											=	num_labels
							snake_case_		:			Union[str, Any]											=	num_choices
							snake_case_		:			Any											=	scope






						def UpperCAmelCase_				(      self      :      Optional[int]	)							->    Optional[int]:







							"""simple docstring"""


							return MPNetConfig.from_pretrained('microsoft/mpnet-base'	)






						def UpperCAmelCase_				(      self      :      List[Any]	)							->    Any:







							"""simple docstring"""


							snake_case_		:			Optional[Any]											=	ids_tensor([self.batch_size, self.seq_length]		,   self.vocab_size	)

							snake_case_		:			Union[str, Any]											=	None
							if self.use_input_mask:
								snake_case_		:			List[str]											=	random_attention_mask([self.batch_size, self.seq_length]	)

							snake_case_		:			Dict											=	None
							snake_case_		:			Any											=	None
							snake_case_		:			List[Any]											=	None
							if self.use_labels:
								snake_case_		:			Optional[Any]											=	ids_tensor([self.batch_size]		,   self.type_sequence_label_size	)
								snake_case_		:			List[str]											=	ids_tensor([self.batch_size, self.seq_length]		,   self.num_labels	)
								snake_case_		:			Dict											=	ids_tensor([self.batch_size]		,   self.num_choices	)

							snake_case_		:			int											=	self.get_config()
							return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels






						def UpperCAmelCase_				(      self      :      List[str]	)							->    List[Any]:







							"""simple docstring"""


							return MPNetConfig(
							    vocab_size=self.vocab_size		,   hidden_size=self.hidden_size		,   num_hidden_layers=self.num_hidden_layers		,   num_attention_heads=self.num_attention_heads		,   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		,   max_position_embeddings=self.max_position_embeddings		,   initializer_range=self.initializer_range		,   )






						def UpperCAmelCase_				(      self      :      Union[str, Any]		,   _A      :      int		,   _A      :      List[str]		,   _A      :      int		,   _A      :      str		,   _A      :      List[str]		,   _A      :      Any	)							->    Tuple:







							"""simple docstring"""


							snake_case_		:			Union[str, Any]											=	MPNetModel(config=_A	)
							model.to(_A	)
							model.eval()
							snake_case_		:			List[str]											=	model(_A		,   _A	)
							snake_case_		:			int											=	model(_A	)
							self.parent.assertEqual(result.last_hidden_state.shape		,   (self.batch_size, self.seq_length, self.hidden_size)	)
							self.parent.assertEqual(result.pooler_output.shape		,   (self.batch_size, self.hidden_size)	)






						def UpperCAmelCase_				(      self      :      Dict		,   _A      :      int		,   _A      :      Union[str, Any]		,   _A      :      List[str]		,   _A      :      Dict		,   _A      :      str		,   _A      :      Dict	)							->    Dict:







							"""simple docstring"""


							snake_case_		:			Optional[Any]											=	MPNetForQuestionAnswering(config=_A	)
							model.to(_A	)
							model.eval()
							snake_case_		:			List[str]											=	model(
							    _A		,   attention_mask=_A		,   start_positions=_A		,   end_positions=_A		,   )
							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 UpperCAmelCase_				(      self      :      int		,   _A      :      Tuple		,   _A      :      Optional[Any]		,   _A      :      Union[str, Any]		,   _A      :      Dict		,   _A      :      Optional[int]		,   _A      :      Optional[int]	)							->    Optional[int]:







							"""simple docstring"""


							snake_case_		:			Optional[int]											=	self.num_labels
							snake_case_		:			Tuple											=	MPNetForSequenceClassification(_A	)
							model.to(_A	)
							model.eval()
							snake_case_		:			Dict											=	model(_A		,   attention_mask=_A		,   labels=_A	)
							self.parent.assertEqual(result.logits.shape		,   (self.batch_size, self.num_labels)	)






						def UpperCAmelCase_				(      self      :      Dict		,   _A      :      List[Any]		,   _A      :      Any		,   _A      :      Union[str, Any]		,   _A      :      Dict		,   _A      :      List[Any]		,   _A      :      Optional[int]	)							->    Union[str, Any]:







							"""simple docstring"""


							snake_case_		:			List[str]											=	self.num_choices
							snake_case_		:			Optional[Any]											=	MPNetForMultipleChoice(config=_A	)
							model.to(_A	)
							model.eval()
							snake_case_		:			List[str]											=	input_ids.unsqueeze(1	).expand(-1		,   self.num_choices		,   -1	).contiguous()
							snake_case_		:			Any											=	input_mask.unsqueeze(1	).expand(-1		,   self.num_choices		,   -1	).contiguous()
							snake_case_		:			List[Any]											=	model(
							    _A		,   attention_mask=_A		,   labels=_A		,   )
							self.parent.assertEqual(result.logits.shape		,   (self.batch_size, self.num_choices)	)






						def UpperCAmelCase_				(      self      :      Any		,   _A      :      Any		,   _A      :      Optional[int]		,   _A      :      List[str]		,   _A      :      Any		,   _A      :      List[str]		,   _A      :      Tuple	)							->    Dict:







							"""simple docstring"""


							snake_case_		:			str											=	self.num_labels
							snake_case_		:			int											=	MPNetForTokenClassification(config=_A	)
							model.to(_A	)
							model.eval()
							snake_case_		:			Any											=	model(_A		,   attention_mask=_A		,   labels=_A	)
							self.parent.assertEqual(result.logits.shape		,   (self.batch_size, self.seq_length, self.num_labels)	)






						def UpperCAmelCase_				(      self      :      Union[str, Any]	)							->    Optional[int]:







							"""simple docstring"""


							snake_case_		:			Dict											=	self.prepare_config_and_inputs()
							((snake_case_)						,(snake_case_)						,(snake_case_)						,(snake_case_)						,(snake_case_)						,(snake_case_))		:			Any											=	config_and_inputs
							snake_case_		:			Tuple											=	{'input_ids': input_ids, 'attention_mask': input_mask}
							return config, inputs_dict
@require_torch
class SCREAMING_SNAKE_CASE_						(					snake_case_       ,				snake_case_       ,				unittest.TestCase					):
						__magic_name__:			Union[str, Any]       =       (
						    (
						        MPNetForMaskedLM,
						        MPNetForMultipleChoice,
						        MPNetForQuestionAnswering,
						        MPNetForSequenceClassification,
						        MPNetForTokenClassification,
						        MPNetModel,
						    )
						    if is_torch_available()
						    else ()
						)
						__magic_name__:			Optional[int]       =       (
						    {
						        "feature-extraction": MPNetModel,
						        "fill-mask": MPNetForMaskedLM,
						        "question-answering": MPNetForQuestionAnswering,
						        "text-classification": MPNetForSequenceClassification,
						        "token-classification": MPNetForTokenClassification,
						        "zero-shot": MPNetForSequenceClassification,
						    }
						    if is_torch_available()
						    else {}
						)
						__magic_name__:			Optional[Any]       =       False
						__magic_name__:			Union[str, Any]       =       True






						def UpperCAmelCase_				(      self      :      Any	)							->    Any:







							"""simple docstring"""


							snake_case_		:			Tuple											=	MPNetModelTester(self	)
							snake_case_		:			Tuple											=	ConfigTester(self		,   config_class=_A		,   hidden_size=37	)






						def UpperCAmelCase_				(      self      :      Any	)							->    Tuple:







							"""simple docstring"""


							self.config_tester.run_common_tests()






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







							"""simple docstring"""


							snake_case_		:			Union[str, Any]											=	self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_mpnet_model(*_A	)






						def UpperCAmelCase_				(      self      :      Dict	)							->    List[Any]:







							"""simple docstring"""


							snake_case_		:			Optional[int]											=	self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_mpnet_for_sequence_classification(*_A	)






						def UpperCAmelCase_				(      self      :      Tuple	)							->    Dict:







							"""simple docstring"""


							snake_case_		:			Optional[int]											=	self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_mpnet_for_multiple_choice(*_A	)






						def UpperCAmelCase_				(      self      :      Tuple	)							->    List[Any]:







							"""simple docstring"""


							snake_case_		:			Union[str, Any]											=	self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_mpnet_for_token_classification(*_A	)






						def UpperCAmelCase_				(      self      :      Dict	)							->    Union[str, Any]:







							"""simple docstring"""


							snake_case_		:			List[str]											=	self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_mpnet_for_question_answering(*_A	)
@require_torch
class SCREAMING_SNAKE_CASE_						(					unittest.TestCase					):






						@slow
						def UpperCAmelCase_				(      self      :      Dict	)							->    int:







							"""simple docstring"""


							snake_case_		:			List[Any]											=	MPNetModel.from_pretrained('microsoft/mpnet-base'	)
							snake_case_		:			str											=	torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]	)
							snake_case_		:			List[str]											=	model(_A	)[0]
							snake_case_		:			Optional[Any]											=	torch.Size((1, 11, 768)	)
							self.assertEqual(output.shape		,   _A	)
							snake_case_		:			str											=	torch.tensor(
							    [[[-0.0_5_5_0, 0.1_9_4_3, -0.0_7_4_0], [-0.0_5_6_2, 0.2_2_1_1, -0.0_5_7_9], [-0.0_4_3_7, 0.3_3_3_7, -0.0_6_4_1]]]	)
							# compare the actual values for a slice.
							self.assertTrue(torch.allclose(output[:, :3, :3]		,   _A		,   atol=1E-4	)	)








import webbrowser
from sys import argv
from urllib.parse import parse_qs, quote

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
						_SCREAMING_SNAKE_CASE      	=		"""%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """)))

						print("""Googling.....""")

						_SCREAMING_SNAKE_CASE      	=		F'''https://www.google.com/search?q={query}&num=100'''

						_SCREAMING_SNAKE_CASE      	=		requests.get(
						    url,
						    headers={"""User-Agent""": str(UserAgent().random)},
						)

						try:
												_SCREAMING_SNAKE_CASE      	=		(
												    BeautifulSoup(res.text, """html.parser""")
												    .find("""div""", attrs={"""class""": """yuRUbf"""})
												    .find("""a""")
												    .get("""href""")
												)

						except AttributeError:
												_SCREAMING_SNAKE_CASE      	=		parse_qs(
												    BeautifulSoup(res.text, """html.parser""")
												    .find("""div""", attrs={"""class""": """kCrYT"""})
												    .find("""a""")
												    .get("""href""")
												)["""url"""][0]

						webbrowser.open(link)

