
def 							_lowerCamelCase			(					lowerCamelCase_:  str				,	lowerCamelCase_:  Union[str, Any]		):



				'''simple docstring'''







				A     :  List[Any]   =				(boundary[1] - boundary[0]) / steps
				A     :  Any   =				boundary[0]
				A     :  Dict   =				boundary[1]
				A     :  Union[str, Any]   =				make_points(lowerCamelCase_				,	lowerCamelCase_				,	lowerCamelCase_		)
				A     :  str   =				0.0
				y += (h / 3.0) * f(lowerCamelCase_		)
				A     :  Tuple   =				2
				for i in x_i:
								y += (h / 3) * (4 - 2 * (cnt % 2)) * f(lowerCamelCase_		)
								cnt += 1
				y += (h / 3.0) * f(lowerCamelCase_		)
				return y





def 							_lowerCamelCase			(					lowerCamelCase_:  str				,	lowerCamelCase_:  Tuple				,	lowerCamelCase_:  List[str]		):



				'''simple docstring'''







				A     :  Tuple   =				a + h
				while x < (b - h):
								yield x
								A     :  str   =				x + h





def 							_lowerCamelCase			(					lowerCamelCase_:  int		):  # enter your function here



				'''simple docstring'''







				A     :  Any   =				(x - 0) * (x - 0)
				return y





def 							_lowerCamelCase			(					):



				'''simple docstring'''







				A     :  List[str]   =				0.0  # Lower bound of integration
				A     :  Optional[Any]   =				1.0  # Upper bound of integration
				A     :  int   =				10.0  # define number of steps or resolution
				A     :  Any   =				[a, b]  # define boundary of integration
				A     :  Tuple   =				method_a(lowerCamelCase_				,	lowerCamelCase_		)
				print(f"""y = {y}"""		)


if __name__ == "__main__":
					main()

import unittest

from transformers import YosoConfig, 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, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch

					from transformers import (
					    YosoForMaskedLM,
					    YosoForMultipleChoice,
					    YosoForQuestionAnswering,
					    YosoForSequenceClassification,
					    YosoForTokenClassification,
					    YosoModel,
					)
					from transformers.models.yoso.modeling_yoso import YOSO_PRETRAINED_MODEL_ARCHIVE_LIST

class     _SCREAMING_SNAKE_CASE							:





				def __init__(		self :		Dict					,      snake_case_ :		Tuple					,      snake_case_ :		Union[str, Any]=13					,      snake_case_ :		int=7					,      snake_case_ :		int=True					,      snake_case_ :		int=True					,      snake_case_ :		Optional[Any]=True					,      snake_case_ :		Optional[int]=True					,      snake_case_ :		Tuple=99					,      snake_case_ :		List[str]=32					,      snake_case_ :		Any=5					,      snake_case_ :		Union[str, Any]=4					,      snake_case_ :		List[Any]=37					,      snake_case_ :		str="gelu"					,      snake_case_ :		int=0.1					,      snake_case_ :		Optional[Any]=0.1					,      snake_case_ :		Union[str, Any]=512					,      snake_case_ :		Optional[int]=16					,      snake_case_ :		Any=2					,      snake_case_ :		Union[str, Any]=0.02					,      snake_case_ :		List[str]=3					,      snake_case_ :		List[str]=4					,      snake_case_ :		Optional[int]=None					,      ):


								"""simple docstring"""

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





				def        _UpperCAmelCase						(		self :		Any							):


								"""simple docstring"""

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

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

								A     :  int   =				None
								if self.use_token_type_ids:
												A     :  str   =				ids_tensor([self.batch_size, self.seq_length]					,      self.type_vocab_size							)

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

								A     :  Dict   =				self.get_config()

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





				def        _UpperCAmelCase						(		self :		Dict							):


								"""simple docstring"""

								return YosoConfig(
								    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=snake_case_					,      initializer_range=self.initializer_range					,      )





				def        _UpperCAmelCase						(		self :		Optional[int]							):


								"""simple docstring"""

								A     :  List[Any]   =				self.get_config()
								A     :  Tuple   =				300
								return config





				def        _UpperCAmelCase						(		self :		List[Any]							):


								"""simple docstring"""

								(
								    (
								    A
								) ,       (
								    A
								) ,       (
								    A
								) ,       (
								    A
								) ,       (
								    A
								) ,       (
								    A
								) ,       (
								    A
								) ,       
								)     :  List[Any]   =				self.prepare_config_and_inputs()

								A     :  Tuple   =				True
								A     :  Tuple   =				floats_tensor([self.batch_size, self.seq_length, self.hidden_size]							)
								A     :  Union[str, Any]   =				ids_tensor([self.batch_size, self.seq_length]					,      vocab_size=2							)

								return (
								    config,
								    input_ids,
								    token_type_ids,
								    input_mask,
								    sequence_labels,
								    token_labels,
								    choice_labels,
								    encoder_hidden_states,
								    encoder_attention_mask,
								)





				def        _UpperCAmelCase						(		self :		Dict					,      snake_case_ :		int					,      snake_case_ :		Optional[Any]					,      snake_case_ :		Union[str, Any]					,      snake_case_ :		Union[str, Any]					,      snake_case_ :		List[str]					,      snake_case_ :		Tuple					,      snake_case_ :		List[str]							):


								"""simple docstring"""

								A     :  Optional[Any]   =				YosoModel(config=snake_case_							)
								model.to(snake_case_							)
								model.eval()
								A     :  List[str]   =				model(snake_case_					,      attention_mask=snake_case_					,      token_type_ids=snake_case_							)
								A     :  int   =				model(snake_case_					,      token_type_ids=snake_case_							)
								A     :  int   =				model(snake_case_							)
								self.parent.assertEqual(result.last_hidden_state.shape					,      (self.batch_size, self.seq_length, self.hidden_size)							)





				def        _UpperCAmelCase						(		self :		List[str]					,      snake_case_ :		int					,      snake_case_ :		Tuple					,      snake_case_ :		List[str]					,      snake_case_ :		str					,      snake_case_ :		int					,      snake_case_ :		List[str]					,      snake_case_ :		Union[str, Any]					,      snake_case_ :		Optional[int]					,      snake_case_ :		int					,      ):


								"""simple docstring"""

								A     :  List[str]   =				True
								A     :  Tuple   =				YosoModel(snake_case_							)
								model.to(snake_case_							)
								model.eval()
								A     :  str   =				model(
								    snake_case_					,      attention_mask=snake_case_					,      token_type_ids=snake_case_					,      encoder_hidden_states=snake_case_					,      encoder_attention_mask=snake_case_					,      )
								A     :  Any   =				model(
								    snake_case_					,      attention_mask=snake_case_					,      token_type_ids=snake_case_					,      encoder_hidden_states=snake_case_					,      )
								A     :  List[Any]   =				model(snake_case_					,      attention_mask=snake_case_					,      token_type_ids=snake_case_							)
								self.parent.assertEqual(result.last_hidden_state.shape					,      (self.batch_size, self.seq_length, self.hidden_size)							)





				def        _UpperCAmelCase						(		self :		Tuple					,      snake_case_ :		Union[str, Any]					,      snake_case_ :		List[str]					,      snake_case_ :		Any					,      snake_case_ :		Union[str, Any]					,      snake_case_ :		int					,      snake_case_ :		Tuple					,      snake_case_ :		str							):


								"""simple docstring"""

								A     :  List[Any]   =				YosoForMaskedLM(config=snake_case_							)
								model.to(snake_case_							)
								model.eval()
								A     :  List[Any]   =				model(snake_case_					,      attention_mask=snake_case_					,      token_type_ids=snake_case_					,      labels=snake_case_							)
								self.parent.assertEqual(result.logits.shape					,      (self.batch_size, self.seq_length, self.vocab_size)							)





				def        _UpperCAmelCase						(		self :		Union[str, Any]					,      snake_case_ :		Tuple					,      snake_case_ :		str					,      snake_case_ :		Dict					,      snake_case_ :		Any					,      snake_case_ :		Optional[int]					,      snake_case_ :		int					,      snake_case_ :		Tuple							):


								"""simple docstring"""

								A     :  Optional[int]   =				YosoForQuestionAnswering(config=snake_case_							)
								model.to(snake_case_							)
								model.eval()
								A     :  int   =				model(
								    snake_case_					,      attention_mask=snake_case_					,      token_type_ids=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        _UpperCAmelCase						(		self :		Tuple					,      snake_case_ :		Any					,      snake_case_ :		List[Any]					,      snake_case_ :		List[Any]					,      snake_case_ :		Optional[Any]					,      snake_case_ :		List[Any]					,      snake_case_ :		Optional[Any]					,      snake_case_ :		str							):


								"""simple docstring"""

								A     :  List[str]   =				self.num_labels
								A     :  int   =				YosoForSequenceClassification(snake_case_							)
								model.to(snake_case_							)
								model.eval()
								A     :  Optional[int]   =				model(snake_case_					,      attention_mask=snake_case_					,      token_type_ids=snake_case_					,      labels=snake_case_							)
								self.parent.assertEqual(result.logits.shape					,      (self.batch_size, self.num_labels)							)





				def        _UpperCAmelCase						(		self :		Any					,      snake_case_ :		Any					,      snake_case_ :		Any					,      snake_case_ :		Union[str, Any]					,      snake_case_ :		Tuple					,      snake_case_ :		Union[str, Any]					,      snake_case_ :		Tuple					,      snake_case_ :		int							):


								"""simple docstring"""

								A     :  List[str]   =				self.num_labels
								A     :  Optional[Any]   =				YosoForTokenClassification(config=snake_case_							)
								model.to(snake_case_							)
								model.eval()
								A     :  Dict   =				model(snake_case_					,      attention_mask=snake_case_					,      token_type_ids=snake_case_					,      labels=snake_case_							)
								self.parent.assertEqual(result.logits.shape					,      (self.batch_size, self.seq_length, self.num_labels)							)





				def        _UpperCAmelCase						(		self :		int					,      snake_case_ :		List[str]					,      snake_case_ :		List[Any]					,      snake_case_ :		str					,      snake_case_ :		Tuple					,      snake_case_ :		Any					,      snake_case_ :		Optional[int]					,      snake_case_ :		str							):


								"""simple docstring"""

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






				def        _UpperCAmelCase						(		self :		Tuple							):


								"""simple docstring"""

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



@require_torch
class     _SCREAMING_SNAKE_CASE							(		snake_case,    snake_case,    unittest.TestCase							):
				lowerCamelCase_       =     (
				    (
				        YosoModel,
				        YosoForMaskedLM,
				        YosoForMultipleChoice,
				        YosoForQuestionAnswering,
				        YosoForSequenceClassification,
				        YosoForTokenClassification,
				    )
				    if is_torch_available()
				    else ()
				)
				lowerCamelCase_       =     False
				lowerCamelCase_       =     False
				lowerCamelCase_       =     False

				lowerCamelCase_       =     ()
				lowerCamelCase_       =     (
				    {
				        'feature-extraction': YosoModel,
				        'fill-mask': YosoForMaskedLM,
				        'question-answering': YosoForQuestionAnswering,
				        'text-classification': YosoForSequenceClassification,
				        'token-classification': YosoForTokenClassification,
				        'zero-shot': YosoForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)





				def        _UpperCAmelCase						(		self :		Optional[int]							):


								"""simple docstring"""

								A     :  Optional[Any]   =				YosoModelTester(self							)
								A     :  Dict   =				ConfigTester(self					,      config_class=snake_case_					,      hidden_size=37							)





				def        _UpperCAmelCase						(		self :		Optional[Any]							):


								"""simple docstring"""

								self.config_tester.run_common_tests()





				def        _UpperCAmelCase						(		self :		int							):


								"""simple docstring"""

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





				def        _UpperCAmelCase						(		self :		int							):


								"""simple docstring"""

								A     :  Optional[Any]   =				self.model_tester.prepare_config_and_inputs()
								for type in ["absolute", "relative_key", "relative_key_query"]:
												A     :  Dict   =				type
												self.model_tester.create_and_check_model(*snake_case_							)





				def        _UpperCAmelCase						(		self :		str							):


								"""simple docstring"""

								A     :  Tuple   =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_masked_lm(*snake_case_							)





				def        _UpperCAmelCase						(		self :		Union[str, Any]							):


								"""simple docstring"""

								A     :  Any   =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_multiple_choice(*snake_case_							)





				def        _UpperCAmelCase						(		self :		Optional[Any]							):


								"""simple docstring"""

								A     :  List[str]   =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_question_answering(*snake_case_							)





				def        _UpperCAmelCase						(		self :		Dict							):


								"""simple docstring"""

								A     :  Dict   =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_sequence_classification(*snake_case_							)





				def        _UpperCAmelCase						(		self :		List[str]							):


								"""simple docstring"""

								A     :  Dict   =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_token_classification(*snake_case_							)





				@slow
				def        _UpperCAmelCase						(		self :		Tuple							):


								"""simple docstring"""

								for model_name in YOSO_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												A     :  Dict   =				YosoModel.from_pretrained(snake_case_							)
												self.assertIsNotNone(snake_case_							)






				def        _UpperCAmelCase						(		self :		Union[str, Any]							):


								"""simple docstring"""

								return



@require_torch
class     _SCREAMING_SNAKE_CASE							(		unittest.TestCase							):





				@slow
				def        _UpperCAmelCase						(		self :		List[Any]							):


								"""simple docstring"""

								A     :  Optional[int]   =				YosoModel.from_pretrained('''uw-madison/yoso-4096'''							)
								A     :  Any   =				torch.tensor([[0, 1, 2, 3, 4, 5]]							)

								with torch.no_grad():
												A     :  str   =				model(snake_case_							)[0]

								A     :  Union[str, Any]   =				torch.Size((1, 6, 768)							)
								self.assertEqual(output.shape					,      snake_case_							)

								A     :  int   =				torch.tensor(
								    [[[-0.06_11, 0.12_42, 0.08_40], [0.02_80, -0.00_48, 0.11_25], [0.01_06, 0.02_26, 0.07_51]]]							)

								self.assertTrue(torch.allclose(output[:, :3, :3]					,      snake_case_					,      atol=1E-4							)							)





				@slow
				def        _UpperCAmelCase						(		self :		int							):


								"""simple docstring"""

								A     :  Tuple   =				YosoForMaskedLM.from_pretrained('''uw-madison/yoso-4096'''							)
								A     :  Dict   =				torch.tensor([[0, 1, 2, 3, 4, 5]]							)

								with torch.no_grad():
												A     :  str   =				model(snake_case_							)[0]

								A     :  Optional[Any]   =				5_0265

								A     :  Union[str, Any]   =				torch.Size((1, 6, vocab_size)							)
								self.assertEqual(output.shape					,      snake_case_							)

								A     :  str   =				torch.tensor(
								    [[[-2.13_13, -3.72_85, -2.24_07], [-2.70_47, -3.33_14, -2.64_08], [0.06_29, -2.51_66, -0.33_56]]]							)

								self.assertTrue(torch.allclose(output[:, :3, :3]					,      snake_case_					,      atol=1E-4							)							)






				@slow
				def        _UpperCAmelCase						(		self :		Dict							):


								"""simple docstring"""

								A     :  str   =				YosoForMaskedLM.from_pretrained('''uw-madison/yoso-4096'''							)
								A     :  Tuple   =				torch.arange(4096							).unsqueeze(0							)

								with torch.no_grad():
												A     :  Optional[Any]   =				model(snake_case_							)[0]

								A     :  Optional[int]   =				5_0265

								A     :  Tuple   =				torch.Size((1, 4096, vocab_size)							)
								self.assertEqual(output.shape					,      snake_case_							)

								A     :  Optional[Any]   =				torch.tensor(
								    [[[-2.39_14, -4.37_42, -5.09_56], [-4.09_88, -4.23_84, -7.04_06], [-3.14_27, -3.71_92, -6.68_00]]]							)

								self.assertTrue(torch.allclose(output[:, :3, :3]					,      snake_case_					,      atol=1E-4							)							)