


'''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 							__UpperCamelCase				:




	def __init__(   self						,				__a						,				):

						'''simple docstring'''





						__a			:       List[str]					    =  parent
						__a			:       Union[str, Any]					    =  13
						__a			:       Any					    =  7
						__a			:       Optional[int]					    =  True
						__a			:       Tuple					    =  True
						__a			:       Any					    =  False
						__a			:       Optional[int]					    =  True
						__a			:       Optional[Any]					    =  99
						__a			:       str					    =  32
						__a			:       Union[str, Any]					    =  2
						__a			:       Optional[Any]					    =  4
						__a			:       Any					    =  37
						__a			:       str					    =  'gelu'
						__a			:       str					    =  0.1
						__a			:       List[Any]					    =  0.1
						__a			:       List[str]					    =  512
						__a			:       Union[str, Any]					    =  16
						__a			:       Union[str, Any]					    =  2
						__a			:       Optional[Any]					    =  0.02
						__a			:       str					    =  3
						__a			:       List[Any]					    =  4
						__a			:       Union[str, Any]					    =  None




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       str					    =  ids_tensor([self.batch_size, self.seq_length]						,				self.vocab_size							)

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

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

						__a			:       int					    =  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       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a							):

						'''simple docstring'''





						__a			:       int					    =  TFDistilBertModel(config=__a							)
						__a			:       Optional[int]					    =  {'input_ids': input_ids, 'attention_mask': input_mask}

						__a			:       Union[str, Any]					    =  model(__a							)

						__a			:       Dict					    =  [input_ids, input_mask]

						__a			:       Optional[Any]					    =  model(__a							)

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




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a							):

						'''simple docstring'''





						__a			:       Optional[Any]					    =  TFDistilBertForMaskedLM(config=__a							)
						__a			:       str					    =  {'input_ids': input_ids, 'attention_mask': input_mask}
						__a			:       Tuple					    =  model(__a							)
						self.parent.assertEqual(result.logits.shape						,				(self.batch_size, self.seq_length, self.vocab_size)							)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a							):

						'''simple docstring'''





						__a			:       List[Any]					    =  TFDistilBertForQuestionAnswering(config=__a							)
						__a			:       Tuple					    =  {
						    'input_ids': input_ids,
						    'attention_mask': input_mask,
						}
						__a			:       Any					    =  model(__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						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a							):

						'''simple docstring'''





						__a			:       List[str]					    =  self.num_labels
						__a			:       Optional[Any]					    =  TFDistilBertForSequenceClassification(__a							)
						__a			:       Any					    =  {'input_ids': input_ids, 'attention_mask': input_mask}
						__a			:       List[Any]					    =  model(__a							)
						self.parent.assertEqual(result.logits.shape						,				(self.batch_size, self.num_labels)							)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a							):

						'''simple docstring'''





						__a			:       Optional[int]					    =  self.num_choices
						__a			:       Dict					    =  TFDistilBertForMultipleChoice(__a							)
						__a			:       Any					    =  tf.tile(tf.expand_dims(__a						,				1							)						,				(1, self.num_choices, 1)							)
						__a			:       Union[str, Any]					    =  tf.tile(tf.expand_dims(__a						,				1							)						,				(1, self.num_choices, 1)							)
						__a			:       List[Any]					    =  {
						    'input_ids': multiple_choice_inputs_ids,
						    'attention_mask': multiple_choice_input_mask,
						}
						__a			:       Optional[Any]					    =  model(__a							)
						self.parent.assertEqual(result.logits.shape						,				(self.batch_size, self.num_choices)							)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a							):

						'''simple docstring'''





						__a			:       Tuple					    =  self.num_labels
						__a			:       Union[str, Any]					    =  TFDistilBertForTokenClassification(__a							)
						__a			:       str					    =  {'input_ids': input_ids, 'attention_mask': input_mask}
						__a			:       Union[str, Any]					    =  model(__a							)
						self.parent.assertEqual(result.logits.shape						,				(self.batch_size, self.seq_length, self.num_labels)							)





	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Dict					    =  self.prepare_config_and_inputs()
						((__a)    ,				(__a)    ,				(__a)    ,				(__a)    ,				(__a)    ,				(__a))			:       Any					    =  config_and_inputs
						__a			:       str					    =  {'input_ids': input_ids, 'attention_mask': input_mask}
						return config, inputs_dict





@require_tf
class 							__UpperCamelCase				(		lowerCAmelCase_		,      lowerCAmelCase_		,      unittest.TestCase					):
	A_				=    (
	    (
	        TFDistilBertModel,
	        TFDistilBertForMaskedLM,
	        TFDistilBertForQuestionAnswering,
	        TFDistilBertForSequenceClassification,
	        TFDistilBertForTokenClassification,
	        TFDistilBertForMultipleChoice,
	    )
	    if is_tf_available()
	    else None
	)
	A_				=    (
	    {
	        "feature-extraction": TFDistilBertModel,
	        "fill-mask": TFDistilBertForMaskedLM,
	        "question-answering": TFDistilBertForQuestionAnswering,
	        "text-classification": TFDistilBertForSequenceClassification,
	        "token-classification": TFDistilBertForTokenClassification,
	        "zero-shot": TFDistilBertForSequenceClassification,
	    }
	    if is_tf_available()
	    else {}
	)
	A_				=    False
	A_				=    False




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Tuple					    =  TFDistilBertModelTester(self							)
						__a			:       Optional[int]					    =  ConfigTester(self						,				config_class=__a						,				dim=37							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						self.config_tester.run_common_tests()




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Optional[int]					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_model(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       List[str]					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_masked_lm(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       str					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_question_answering(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Any					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_sequence_classification(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       List[Any]					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_multiple_choice(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Tuple					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_token_classification(*__a							)





	@slow
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						for model_name in list(TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]							):
											__a			:       List[str]					    =  TFDistilBertModel.from_pretrained(__a							)
											self.assertIsNotNone(__a							)





@require_tf
class 							__UpperCamelCase				(		unittest.TestCase					):




	@slow
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       List[str]					    =  TFDistilBertModel.from_pretrained('distilbert-base-uncased'							)
						__a			:       Optional[Any]					    =  tf.constant([[0, 1, 2, 3, 4, 5]]							)
						__a			:       int					    =  model(__a							)[0]

						__a			:       str					    =  [1, 6, 768]
						self.assertEqual(output.shape						,				__a							)

						__a			:       List[Any]					    =  tf.constant(
						    [
						        [
						            [0.19261885, -0.13732955, 0.4119799],
						            [0.22150156, -0.07422661, 0.39037204],
						            [0.22756018, -0.0896414, 0.3701467],
						        ]
						    ]							)
						tf.debugging.assert_near(output[:, :3, :3]						,				__a						,				atol=1E-4							)







'''simple docstring'''



import requests
from bsa import BeautifulSoup






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE      :   str = "https://www.worldometers.info/coronavirus"   ):
					__a			:       List[Any]					    =  BeautifulSoup(requests.get(_SCREAMING_SNAKE_CASE   ).text						,      'html.parser'   )
					__a			:       Union[str, Any]					    =  soup.findAll('h1'   )
					__a			:       int					    =  soup.findAll('div'						,      {'class': 'maincounter-number'}   )
					keys += soup.findAll('span'						,      {'class': 'panel-title'}   )
					values += soup.findAll('div'						,      {'class': 'number-table-main'}   )
					return {key.text.strip(): value.text.strip() for key, value in zip(_SCREAMING_SNAKE_CASE						,      _SCREAMING_SNAKE_CASE   )}


if __name__ == "__main__":
	print('\033[1m' + 'COVID-19 Status of the World' + '\033[0m\n')
	for key, value in world_covidaa_stats().items():
		print(f'''{key}\n{value}\n''')



