




'''simple docstring'''






import unittest

from transformers import SqueezeBertConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, 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 (
						    SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    SqueezeBertForMaskedLM,
						    SqueezeBertForMultipleChoice,
						    SqueezeBertForQuestionAnswering,
						    SqueezeBertForSequenceClassification,
						    SqueezeBertForTokenClassification,
						    SqueezeBertModel,
						)

class        SCREAMING_SNAKE_CASE(							A__    ):







	"""simple docstring"""






	def __init__(		self    :  List[Any]	,    __snake_case    :  Any	,    __snake_case    :  Dict=13	,    __snake_case    :  Optional[Any]=7	,    __snake_case    :  List[str]=True	,    __snake_case    :  Any=True	,    __snake_case    :  Dict=False	,    __snake_case    :  Any=True	,    __snake_case    :  Optional[Any]=99	,    __snake_case    :  int=32	,    __snake_case    :  Union[str, Any]=5	,    __snake_case    :  str=4	,    __snake_case    :  Optional[int]=64	,    __snake_case    :  Tuple="gelu"	,    __snake_case    :  Tuple=0.1	,    __snake_case    :  List[str]=0.1	,    __snake_case    :  Optional[int]=512	,    __snake_case    :  Any=16	,    __snake_case    :  Optional[int]=2	,    __snake_case    :  List[str]=0.02	,    __snake_case    :  str=3	,    __snake_case    :  int=4	,    __snake_case    :  Optional[Any]=None	,    __snake_case    :  List[str]=2	,    __snake_case    :  str=2	,    __snake_case    :  List[Any]=2	,    __snake_case    :  Union[str, Any]=2	,    __snake_case    :  str=4	,    __snake_case    :  Tuple=1	,    )    ->	Union[str, Any]:
								UpperCAmelCase				: Any											=	parent
								UpperCAmelCase				: Any											=	batch_size
								UpperCAmelCase				: Tuple											=	seq_length
								UpperCAmelCase				: Union[str, Any]											=	is_training
								UpperCAmelCase				: List[str]											=	use_input_mask
								UpperCAmelCase				: int											=	use_token_type_ids
								UpperCAmelCase				: Optional[int]											=	use_labels
								UpperCAmelCase				: Optional[Any]											=	vocab_size
								UpperCAmelCase				: Any											=	hidden_size
								UpperCAmelCase				: Dict											=	num_hidden_layers
								UpperCAmelCase				: List[str]											=	num_attention_heads
								UpperCAmelCase				: int											=	intermediate_size
								UpperCAmelCase				: List[Any]											=	hidden_act
								UpperCAmelCase				: Dict											=	hidden_dropout_prob
								UpperCAmelCase				: List[Any]											=	attention_probs_dropout_prob
								UpperCAmelCase				: Dict											=	max_position_embeddings
								UpperCAmelCase				: Tuple											=	type_vocab_size
								UpperCAmelCase				: Optional[Any]											=	type_sequence_label_size
								UpperCAmelCase				: List[Any]											=	initializer_range
								UpperCAmelCase				: str											=	num_labels
								UpperCAmelCase				: List[str]											=	num_choices
								UpperCAmelCase				: List[str]											=	scope
								UpperCAmelCase				: Any											=	q_groups
								UpperCAmelCase				: Optional[Any]											=	k_groups
								UpperCAmelCase				: Any											=	v_groups
								UpperCAmelCase				: str											=	post_attention_groups
								UpperCAmelCase				: str											=	intermediate_groups
								UpperCAmelCase				: int											=	output_groups







	def   A			(		self    :  Union[str, Any]	)    ->	str:
								UpperCAmelCase				: Union[str, Any]											=	ids_tensor([self.batch_size, self.seq_length]	,    self.vocab_size	)

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

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

								UpperCAmelCase				: List[Any]											=	self.get_config()

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







	def   A			(		self    :  Union[str, Any]	)    ->	Optional[int]:
								return SqueezeBertConfig(
								    embedding_size=self.hidden_size	,    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	,    attention_probs_dropout_prob=self.hidden_dropout_prob	,    attention_dropout=self.attention_probs_dropout_prob	,    max_position_embeddings=self.max_position_embeddings	,    initializer_range=self.initializer_range	,    q_groups=self.q_groups	,    k_groups=self.k_groups	,    v_groups=self.v_groups	,    post_attention_groups=self.post_attention_groups	,    intermediate_groups=self.intermediate_groups	,    output_groups=self.output_groups	,    )







	def   A			(		self    :  Dict	,    __snake_case    :  str	,    __snake_case    :  Union[str, Any]	,    __snake_case    :  str	,    __snake_case    :  Union[str, Any]	,    __snake_case    :  Optional[int]	,    __snake_case    :  Optional[Any]	)    ->	Optional[int]:
								UpperCAmelCase				: Optional[Any]											=	SqueezeBertModel(config=__snake_case	)
								model.to(__snake_case	)
								model.eval()
								UpperCAmelCase				: Tuple											=	model(__snake_case	,    __snake_case	)
								UpperCAmelCase				: Optional[int]											=	model(__snake_case	)
								self.parent.assertEqual(result.last_hidden_state.shape	,    (self.batch_size, self.seq_length, self.hidden_size)	)







	def   A			(		self    :  Union[str, Any]	,    __snake_case    :  List[Any]	,    __snake_case    :  Optional[Any]	,    __snake_case    :  Tuple	,    __snake_case    :  List[str]	,    __snake_case    :  Tuple	,    __snake_case    :  str	)    ->	int:
								UpperCAmelCase				: Dict											=	SqueezeBertForMaskedLM(config=__snake_case	)
								model.to(__snake_case	)
								model.eval()
								UpperCAmelCase				: List[str]											=	model(__snake_case	,    attention_mask=__snake_case	,    labels=__snake_case	)
								self.parent.assertEqual(result.logits.shape	,    (self.batch_size, self.seq_length, self.vocab_size)	)







	def   A			(		self    :  Optional[Any]	,    __snake_case    :  Any	,    __snake_case    :  Dict	,    __snake_case    :  Optional[int]	,    __snake_case    :  Tuple	,    __snake_case    :  Tuple	,    __snake_case    :  int	)    ->	List[Any]:
								UpperCAmelCase				: Any											=	SqueezeBertForQuestionAnswering(config=__snake_case	)
								model.to(__snake_case	)
								model.eval()
								UpperCAmelCase				: Any											=	model(
								    __snake_case	,    attention_mask=__snake_case	,    start_positions=__snake_case	,    end_positions=__snake_case	)
								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   A			(		self    :  Optional[int]	,    __snake_case    :  int	,    __snake_case    :  Dict	,    __snake_case    :  Dict	,    __snake_case    :  Optional[Any]	,    __snake_case    :  Tuple	,    __snake_case    :  Dict	)    ->	Tuple:
								UpperCAmelCase				: Optional[int]											=	self.num_labels
								UpperCAmelCase				: List[Any]											=	SqueezeBertForSequenceClassification(__snake_case	)
								model.to(__snake_case	)
								model.eval()
								UpperCAmelCase				: int											=	model(__snake_case	,    attention_mask=__snake_case	,    labels=__snake_case	)
								self.parent.assertEqual(result.logits.shape	,    (self.batch_size, self.num_labels)	)







	def   A			(		self    :  Dict	,    __snake_case    :  Any	,    __snake_case    :  Dict	,    __snake_case    :  List[Any]	,    __snake_case    :  Optional[Any]	,    __snake_case    :  str	,    __snake_case    :  List[Any]	)    ->	Any:
								UpperCAmelCase				: str											=	self.num_labels
								UpperCAmelCase				: Optional[Any]											=	SqueezeBertForTokenClassification(config=__snake_case	)
								model.to(__snake_case	)
								model.eval()

								UpperCAmelCase				: str											=	model(__snake_case	,    attention_mask=__snake_case	,    labels=__snake_case	)
								self.parent.assertEqual(result.logits.shape	,    (self.batch_size, self.seq_length, self.num_labels)	)







	def   A			(		self    :  List[str]	,    __snake_case    :  Dict	,    __snake_case    :  Tuple	,    __snake_case    :  Optional[int]	,    __snake_case    :  Optional[Any]	,    __snake_case    :  List[str]	,    __snake_case    :  Dict	)    ->	str:
								UpperCAmelCase				: Union[str, Any]											=	self.num_choices
								UpperCAmelCase				: int											=	SqueezeBertForMultipleChoice(config=__snake_case	)
								model.to(__snake_case	)
								model.eval()
								UpperCAmelCase				: Optional[Any]											=	input_ids.unsqueeze(1	).expand(-1	,    self.num_choices	,    -1	).contiguous()
								UpperCAmelCase				: Union[str, Any]											=	input_mask.unsqueeze(1	).expand(-1	,    self.num_choices	,    -1	).contiguous()
								UpperCAmelCase				: Any											=	model(
								    __snake_case	,    attention_mask=__snake_case	,    labels=__snake_case	,    )
								self.parent.assertEqual(result.logits.shape	,    (self.batch_size, self.num_choices)	)







	def   A			(		self    :  Union[str, Any]	)    ->	str:
								UpperCAmelCase				: Any											=	self.prepare_config_and_inputs()
								(UpperCAmelCase)				: List[str]											=	config_and_inputs
								UpperCAmelCase				: List[str]											=	{'''input_ids''': input_ids, '''attention_mask''': input_mask}
								return config, inputs_dict

@require_torch
class        SCREAMING_SNAKE_CASE(							A__							,	A__							,	unittest.TestCase    ):







	"""simple docstring"""






	lowerCamelCase__    				= (
	    (
	        SqueezeBertModel,
	        SqueezeBertForMaskedLM,
	        SqueezeBertForMultipleChoice,
	        SqueezeBertForQuestionAnswering,
	        SqueezeBertForSequenceClassification,
	        SqueezeBertForTokenClassification,
	    )
	    if is_torch_available()
	    else None
	)
	lowerCamelCase__    				= (
	    {
	        """feature-extraction""": SqueezeBertModel,
	        """fill-mask""": SqueezeBertForMaskedLM,
	        """question-answering""": SqueezeBertForQuestionAnswering,
	        """text-classification""": SqueezeBertForSequenceClassification,
	        """token-classification""": SqueezeBertForTokenClassification,
	        """zero-shot""": SqueezeBertForSequenceClassification,
	    }
	    if is_torch_available()
	    else {}
	)
	lowerCamelCase__    				= False
	lowerCamelCase__    				= True
	lowerCamelCase__    				= False







	def   A			(		self    :  Dict	)    ->	Union[str, Any]:
								UpperCAmelCase				: Dict											=	SqueezeBertModelTester(self	)
								UpperCAmelCase				: Optional[Any]											=	ConfigTester(self	,    config_class=__snake_case	,    dim=37	)







	def   A			(		self    :  List[str]	)    ->	int:
								self.config_tester.run_common_tests()







	def   A			(		self    :  Dict	)    ->	List[Any]:
								UpperCAmelCase				: Any											=	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_squeezebert_model(*__snake_case	)







	def   A			(		self    :  Any	)    ->	Union[str, Any]:
								UpperCAmelCase				: Optional[Any]											=	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_squeezebert_for_masked_lm(*__snake_case	)







	def   A			(		self    :  str	)    ->	Optional[int]:
								UpperCAmelCase				: Dict											=	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_squeezebert_for_question_answering(*__snake_case	)







	def   A			(		self    :  str	)    ->	Any:
								UpperCAmelCase				: Dict											=	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_squeezebert_for_sequence_classification(*__snake_case	)







	def   A			(		self    :  Union[str, Any]	)    ->	Any:
								UpperCAmelCase				: Any											=	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_squeezebert_for_token_classification(*__snake_case	)







	def   A			(		self    :  int	)    ->	Dict:
								UpperCAmelCase				: Optional[Any]											=	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_squeezebert_for_multiple_choice(*__snake_case	)







	@slow
	def   A			(		self    :  Optional[int]	)    ->	List[str]:
								for model_name in SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															UpperCAmelCase				: List[Any]											=	SqueezeBertModel.from_pretrained(__snake_case	)
															self.assertIsNotNone(__snake_case	)

@require_sentencepiece
@require_tokenizers
@require_torch
class        SCREAMING_SNAKE_CASE(							unittest.TestCase    ):







	"""simple docstring"""






	@slow
	def   A			(		self    :  Dict	)    ->	Union[str, Any]:
								UpperCAmelCase				: List[Any]											=	SqueezeBertForSequenceClassification.from_pretrained('''squeezebert/squeezebert-mnli'''	)

								UpperCAmelCase				: str											=	torch.tensor([[1, 29414, 232, 328, 740, 1140, 12695, 69, 13, 1588, 2]]	)
								UpperCAmelCase				: Dict											=	model(__snake_case	)[0]
								UpperCAmelCase				: int											=	torch.Size((1, 3)	)
								self.assertEqual(output.shape	,    __snake_case	)
								UpperCAmelCase				: Dict											=	torch.tensor([[0.64_01, -0.03_49, -0.60_41]]	)
								self.assertTrue(torch.allclose(__snake_case	,    __snake_case	,    atol=1E-4	)	)










'''simple docstring'''






from __future__ import annotations

from collections.abc import Generator

import requests
from bsa import BeautifulSoup

UpperCamelCase__:     Union[str, Any]										=    "https://www.indeed.co.in/jobs?q=mobile+app+development&l="


def 				snake_case_  (      _lowerCAmelCase						:		str = "mumbai"						)   ->     Generator[tuple[str, str], None, None]:
							UpperCAmelCase				: Optional[int]											=	BeautifulSoup(requests.get(url + location						).content     ,   '''html.parser'''						)
							# This attribute finds out all the specifics listed in a job
							for job in soup.find_all('''div'''     ,   attrs={'''data-tn-component''': '''organicJob'''}						):
														UpperCAmelCase				: Optional[Any]											=	job.find('''a'''     ,   attrs={'''data-tn-element''': '''jobTitle'''}						).text.strip()
														UpperCAmelCase				: int											=	job.find('''span'''     ,   {'''class''': '''company'''}						).text.strip()
														yield job_title, company_name


if __name__ == "__main__":
						for i, job in enumerate(fetch_jobs("Bangalore"), 1):
												print(F"Job {i:>2} is {job[0]} at {job[1]}")





