


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 				snake_case__:







						'''simple docstring'''




						def __init__(				self   ,						__lowercase   ,						__lowercase=1_3   ,						__lowercase=7   ,						__lowercase=True   ,						__lowercase=True   ,						__lowercase=False   ,						__lowercase=True   ,						__lowercase=9_9   ,						__lowercase=6_4   ,						__lowercase=5   ,						__lowercase=4   ,						__lowercase=6_4   ,						__lowercase="gelu"   ,						__lowercase=0.1   ,						__lowercase=0.1   ,						__lowercase=5_1_2   ,						__lowercase=1_6   ,						__lowercase=2   ,						__lowercase=0.02   ,						__lowercase=3   ,						__lowercase=4   ,						__lowercase=None   ,						)					->    Optional[int]:
										lowerCAmelCase_ :      str    				=				parent
										lowerCAmelCase_ :      List[Any]    				=				batch_size
										lowerCAmelCase_ :      Any    				=				seq_length
										lowerCAmelCase_ :      int    				=				is_training
										lowerCAmelCase_ :      str    				=				use_input_mask
										lowerCAmelCase_ :      str    				=				use_token_type_ids
										lowerCAmelCase_ :      List[Any]    				=				use_labels
										lowerCAmelCase_ :      Tuple    				=				vocab_size
										lowerCAmelCase_ :      Union[str, Any]    				=				hidden_size
										lowerCAmelCase_ :      int    				=				num_hidden_layers
										lowerCAmelCase_ :      int    				=				num_attention_heads
										lowerCAmelCase_ :      List[Any]    				=				intermediate_size
										lowerCAmelCase_ :      List[Any]    				=				hidden_act
										lowerCAmelCase_ :      str    				=				hidden_dropout_prob
										lowerCAmelCase_ :      Optional[Any]    				=				attention_probs_dropout_prob
										lowerCAmelCase_ :      List[Any]    				=				max_position_embeddings
										lowerCAmelCase_ :      str    				=				type_vocab_size
										lowerCAmelCase_ :      str    				=				type_sequence_label_size
										lowerCAmelCase_ :      Union[str, Any]    				=				initializer_range
										lowerCAmelCase_ :      List[str]    				=				num_labels
										lowerCAmelCase_ :      List[str]    				=				num_choices
										lowerCAmelCase_ :      int    				=				scope




						def 						lowercase_ (				self							)					->    Dict:
										return MPNetConfig.from_pretrained('''microsoft/mpnet-base'''							)




						def 						lowercase_ (				self							)					->    Any:
										lowerCAmelCase_ :      List[Any]    				=				ids_tensor([self.batch_size, self.seq_length]   ,						self.vocab_size							)

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

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

										lowerCAmelCase_ :      Any    				=				self.get_config()
										return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels




						def 						lowercase_ (				self							)					->    int:
										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 						lowercase_ (				self   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase							)					->    Optional[int]:
										lowerCAmelCase_ :      Dict    				=				MPNetModel(config=__lowercase							)
										model.to(__lowercase							)
										model.eval()
										lowerCAmelCase_ :      Tuple    				=				model(__lowercase   ,						__lowercase							)
										lowerCAmelCase_ :      Union[str, Any]    				=				model(__lowercase							)
										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 						lowercase_ (				self   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase							)					->    List[Any]:
										lowerCAmelCase_ :      Tuple    				=				MPNetForQuestionAnswering(config=__lowercase							)
										model.to(__lowercase							)
										model.eval()
										lowerCAmelCase_ :      Optional[Any]    				=				model(
										    __lowercase   ,						attention_mask=__lowercase   ,						start_positions=__lowercase   ,						end_positions=__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 						lowercase_ (				self   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase							)					->    List[Any]:
										lowerCAmelCase_ :      Tuple    				=				self.num_labels
										lowerCAmelCase_ :      List[Any]    				=				MPNetForSequenceClassification(__lowercase							)
										model.to(__lowercase							)
										model.eval()
										lowerCAmelCase_ :      int    				=				model(__lowercase   ,						attention_mask=__lowercase   ,						labels=__lowercase							)
										self.parent.assertEqual(result.logits.shape   ,						(self.batch_size, self.num_labels)							)




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase							)					->    str:
										lowerCAmelCase_ :      Any    				=				self.num_choices
										lowerCAmelCase_ :      List[Any]    				=				MPNetForMultipleChoice(config=__lowercase							)
										model.to(__lowercase							)
										model.eval()
										lowerCAmelCase_ :      str    				=				input_ids.unsqueeze(1							).expand(-1   ,						self.num_choices   ,						-1							).contiguous()
										lowerCAmelCase_ :      Any    				=				input_mask.unsqueeze(1							).expand(-1   ,						self.num_choices   ,						-1							).contiguous()
										lowerCAmelCase_ :      Dict    				=				model(
										    __lowercase   ,						attention_mask=__lowercase   ,						labels=__lowercase   ,						)
										self.parent.assertEqual(result.logits.shape   ,						(self.batch_size, self.num_choices)							)




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase							)					->    int:
										lowerCAmelCase_ :      Optional[Any]    				=				self.num_labels
										lowerCAmelCase_ :      Tuple    				=				MPNetForTokenClassification(config=__lowercase							)
										model.to(__lowercase							)
										model.eval()
										lowerCAmelCase_ :      Union[str, Any]    				=				model(__lowercase   ,						attention_mask=__lowercase   ,						labels=__lowercase							)
										self.parent.assertEqual(result.logits.shape   ,						(self.batch_size, self.seq_length, self.num_labels)							)




						def 						lowercase_ (				self							)					->    Union[str, Any]:
										lowerCAmelCase_ :      Optional[int]    				=				self.prepare_config_and_inputs()
										((lowerCAmelCase_)				,  (lowerCAmelCase_)				,  (lowerCAmelCase_)				,  (lowerCAmelCase_)				,  (lowerCAmelCase_)				,  (lowerCAmelCase_)) :      int    				=				config_and_inputs
										lowerCAmelCase_ :      Tuple    				=				{'''input_ids''': input_ids, '''attention_mask''': input_mask}
										return config, inputs_dict







@require_torch
class 				snake_case__(							UpperCAmelCase__,						UpperCAmelCase__,						unittest.TestCase							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  Dict					=							(
						    (
						        MPNetForMaskedLM,
						        MPNetForMultipleChoice,
						        MPNetForQuestionAnswering,
						        MPNetForSequenceClassification,
						        MPNetForTokenClassification,
						        MPNetModel,
						    )
						    if is_torch_available()
						    else ()
						)
						SCREAMING_SNAKE_CASE__      :  int					=							(
						    {
						        """feature-extraction""": MPNetModel,
						        """fill-mask""": MPNetForMaskedLM,
						        """question-answering""": MPNetForQuestionAnswering,
						        """text-classification""": MPNetForSequenceClassification,
						        """token-classification""": MPNetForTokenClassification,
						        """zero-shot""": MPNetForSequenceClassification,
						    }
						    if is_torch_available()
						    else {}
						)
						SCREAMING_SNAKE_CASE__      :  str					=							False
						SCREAMING_SNAKE_CASE__      :  Tuple					=							True




						def 						lowercase_ (				self							)					->    Optional[Any]:
										lowerCAmelCase_ :      List[str]    				=				MPNetModelTester(self							)
										lowerCAmelCase_ :      Dict    				=				ConfigTester(self   ,						config_class=__lowercase   ,						hidden_size=3_7							)




						def 						lowercase_ (				self							)					->    List[Any]:
										self.config_tester.run_common_tests()




						def 						lowercase_ (				self							)					->    Union[str, Any]:
										lowerCAmelCase_ :      str    				=				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_mpnet_model(*__lowercase							)




						def 						lowercase_ (				self							)					->    Dict:
										lowerCAmelCase_ :      Dict    				=				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_mpnet_for_sequence_classification(*__lowercase							)




						def 						lowercase_ (				self							)					->    int:
										lowerCAmelCase_ :      Optional[Any]    				=				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_mpnet_for_multiple_choice(*__lowercase							)




						def 						lowercase_ (				self							)					->    int:
										lowerCAmelCase_ :      List[Any]    				=				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_mpnet_for_token_classification(*__lowercase							)




						def 						lowercase_ (				self							)					->    Union[str, Any]:
										lowerCAmelCase_ :      Optional[Any]    				=				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_mpnet_for_question_answering(*__lowercase							)







@require_torch
class 				snake_case__(							unittest.TestCase							):







						'''simple docstring'''




						@slow
						def 						lowercase_ (				self							)					->    Union[str, Any]:
										lowerCAmelCase_ :      List[str]    				=				MPNetModel.from_pretrained('''microsoft/mpnet-base'''							)
										lowerCAmelCase_ :      Tuple    				=				torch.tensor([[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]]							)
										lowerCAmelCase_ :      str    				=				model(__lowercase							)[0]
										lowerCAmelCase_ :      List[Any]    				=				torch.Size((1, 1_1, 7_6_8)							)
										self.assertEqual(output.shape   ,						__lowercase							)
										lowerCAmelCase_ :      Union[str, Any]    				=				torch.tensor(
										    [[[-0.05_50, 0.19_43, -0.07_40], [-0.05_62, 0.22_11, -0.05_79], [-0.04_37, 0.33_37, -0.06_41]]]							)
										# compare the actual values for a slice.
										self.assertTrue(torch.allclose(output[:, :3, :3]   ,						__lowercase   ,						atol=1e-4							)							)



import re



def 			lowerCAmelCase (		lowerCAmelCase_ )-> bool:
				lowerCAmelCase_ :      Tuple    				=				re.compile(r'''^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$''' )
				if match := re.search(lowerCAmelCase_ ,   lowerCAmelCase_ ):
								return match.string == phone
				return False


if __name__ == "__main__":
						print(indian_phone_validator("""+918827897895"""))