





import unittest

import numpy as np

from transformers import AlbertConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
		import jax.numpy as jnp

		from transformers.models.albert.modeling_flax_albert import (
		    FlaxAlbertForMaskedLM,
		    FlaxAlbertForMultipleChoice,
		    FlaxAlbertForPreTraining,
		    FlaxAlbertForQuestionAnswering,
		    FlaxAlbertForSequenceClassification,
		    FlaxAlbertForTokenClassification,
		    FlaxAlbertModel,
		)


class 						lowerCamelCase       (unittest.TestCase      ):







							"""simple docstring"""




							def __init__( self     :					Tuple,			_UpperCAmelCase     :					Optional[int],			_UpperCAmelCase     :					List[Any]=1_3,			_UpperCAmelCase     :					Union[str, Any]=7,			_UpperCAmelCase     :					int=True,			_UpperCAmelCase     :					str=True,			_UpperCAmelCase     :					Optional[int]=True,			_UpperCAmelCase     :					List[Any]=True,			_UpperCAmelCase     :					Dict=9_9,			_UpperCAmelCase     :					List[Any]=3_2,			_UpperCAmelCase     :					Optional[int]=5,			_UpperCAmelCase     :					int=4,			_UpperCAmelCase     :					List[str]=3_7,			_UpperCAmelCase     :					Optional[Any]="gelu",			_UpperCAmelCase     :					str=0.1,			_UpperCAmelCase     :					Optional[int]=0.1,			_UpperCAmelCase     :					List[Any]=5_1_2,			_UpperCAmelCase     :					Any=1_6,			_UpperCAmelCase     :					Dict=2,			_UpperCAmelCase     :					List[Any]=0.02,			_UpperCAmelCase     :					Optional[int]=4,			)				->			Any:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						parent
														SCREAMING_SNAKE_CASE__       :      int     =						batch_size
														SCREAMING_SNAKE_CASE__       :      str     =						seq_length
														SCREAMING_SNAKE_CASE__       :      Dict     =						is_training
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						use_attention_mask
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						use_token_type_ids
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						use_labels
														SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						vocab_size
														SCREAMING_SNAKE_CASE__       :      Tuple     =						hidden_size
														SCREAMING_SNAKE_CASE__       :      List[str]     =						num_hidden_layers
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						num_attention_heads
														SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						intermediate_size
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						hidden_act
														SCREAMING_SNAKE_CASE__       :      List[str]     =						hidden_dropout_prob
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						attention_probs_dropout_prob
														SCREAMING_SNAKE_CASE__       :      Tuple     =						max_position_embeddings
														SCREAMING_SNAKE_CASE__       :      str     =						type_vocab_size
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						type_sequence_label_size
														SCREAMING_SNAKE_CASE__       :      Dict     =						initializer_range
														SCREAMING_SNAKE_CASE__       :      List[str]     =						num_choices






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





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Tuple     =						ids_tensor([self.batch_size, self.seq_length],			self.vocab_size						)

														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						None
														if self.use_attention_mask:
																					SCREAMING_SNAKE_CASE__       :      List[str]     =						random_attention_mask([self.batch_size, self.seq_length]						)

														SCREAMING_SNAKE_CASE__       :      Any     =						None
														if self.use_token_type_ids:
																					SCREAMING_SNAKE_CASE__       :      List[Any]     =						ids_tensor([self.batch_size, self.seq_length],			self.type_vocab_size						)

														SCREAMING_SNAKE_CASE__       :      Dict     =						AlbertConfig(
														    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,			type_vocab_size=self.type_vocab_size,			is_decoder=_UpperCAmelCase,			initializer_range=self.initializer_range,			)

														return config, input_ids, token_type_ids, attention_mask






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





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						self.prepare_config_and_inputs()
														SCREAMING_SNAKE_CASE__       :      List[str]     =						config_and_inputs
														SCREAMING_SNAKE_CASE__       :      List[str]     =						{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": attention_mask}
														return config, inputs_dict


@require_flax
class 						lowerCamelCase       (__lowerCamelCase							,     unittest.TestCase      ):







							"""simple docstring"""




							UpperCAmelCase_      						=   (
							    (
							        FlaxAlbertModel,
							        FlaxAlbertForPreTraining,
							        FlaxAlbertForMaskedLM,
							        FlaxAlbertForMultipleChoice,
							        FlaxAlbertForQuestionAnswering,
							        FlaxAlbertForSequenceClassification,
							        FlaxAlbertForTokenClassification,
							        FlaxAlbertForQuestionAnswering,
							    )
							    if is_flax_available()
							    else ()
							)






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





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						FlaxAlbertModelTester(self						)






							@slow
							def  A_     ( self     :					Optional[Any]						)				->			Tuple:





														"""simple docstring"""
														for model_class_name in self.all_model_classes:
																					SCREAMING_SNAKE_CASE__       :      Optional[int]     =						model_class_name.from_pretrained("albert-base-v2"						)
																					SCREAMING_SNAKE_CASE__       :      Tuple     =						model(np.ones((1, 1)						)						)
																					self.assertIsNotNone(_UpperCAmelCase						)


@require_flax
class 						lowerCamelCase       (unittest.TestCase      ):







							"""simple docstring"""




							@slow
							def  A_     ( self     :					Optional[int]						)				->			List[Any]:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      List[str]     =						FlaxAlbertModel.from_pretrained("albert-base-v2"						)
														SCREAMING_SNAKE_CASE__       :      int     =						np.array([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]]						)
														SCREAMING_SNAKE_CASE__       :      int     =						np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]						)
														SCREAMING_SNAKE_CASE__       :      Dict     =						model(_UpperCAmelCase,			attention_mask=_UpperCAmelCase						)[0]
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						(1, 1_1, 7_6_8)
														self.assertEqual(output.shape,			_UpperCAmelCase						)
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						np.array(
														    [[[-0.6513, 1.5035, -0.2766], [-0.6515, 1.5046, -0.2780], [-0.6512, 1.5049, -0.2784]]]						)

														self.assertTrue(jnp.allclose(output[:, 1:4, 1:4],			_UpperCAmelCase,			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__":
		_lowerCamelCase :    Union[str, Any]  							= '''%20'''.join(argv[1:]) if len(argv) > 1 else quote(str(input('''Search: ''')))

		print('''Googling.....''')

		_lowerCamelCase :    Any  							= f"https://www.google.com/search?q={query}&num=100"

		_lowerCamelCase :    Optional[Any]  							= requests.get(
		    url,
		    headers={'''User-Agent''': str(UserAgent().random)},
		)

		try:
				_lowerCamelCase :    Union[str, Any]  							= (
				    BeautifulSoup(res.text, '''html.parser''')
				    .find('''div''', attrs={'''class''': '''yuRUbf'''})
				    .find('''a''')
				    .get('''href''')
				)

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

		webbrowser.open(link)






