



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


						def __init__(			self    :	Optional[Any]   ,							_a    :	Union[str, Any]   ,							_a    :	Optional[int]=1_3   ,							_a    :	List[str]=7   ,							_a    :	Optional[Any]=True   ,							_a    :	Optional[Any]=True   ,							_a    :	List[str]=True   ,							_a    :	Optional[Any]=True   ,							_a    :	Optional[Any]=9_9   ,							_a    :	Optional[Any]=3_2   ,							_a    :	List[Any]=5   ,							_a    :	Optional[Any]=4   ,							_a    :	Dict=3_7   ,							_a    :	Any="gelu"   ,							_a    :	Dict=0.1   ,							_a    :	Any=0.1   ,							_a    :	Any=5_1_2   ,							_a    :	Optional[Any]=1_6   ,							_a    :	Any=2   ,							_a    :	str=0.0_2   ,							_a    :	Union[str, Any]=3   ,							_a    :	Optional[int]=4   ,							_a    :	int=None   ,							):
													a__:							Union[str, Any]									=parent
													a__:							Tuple									=batch_size
													a__:							List[Any]									=seq_length
													a__:							str									=is_training
													a__:							List[str]									=use_input_mask
													a__:							Dict									=use_token_type_ids
													a__:							Optional[int]									=use_labels
													a__:							int									=vocab_size
													a__:							Any									=hidden_size
													a__:							Any									=num_hidden_layers
													a__:							int									=num_attention_heads
													a__:							Union[str, Any]									=intermediate_size
													a__:							Tuple									=hidden_act
													a__:							List[Any]									=hidden_dropout_prob
													a__:							Optional[int]									=attention_probs_dropout_prob
													a__:							Any									=max_position_embeddings
													a__:							List[Any]									=type_vocab_size
													a__:							Any									=type_sequence_label_size
													a__:							Optional[Any]									=initializer_range
													a__:							List[Any]									=num_labels
													a__:							Dict									=num_choices
													a__:							str									=scope


						def 	_lowerCamelCase      (			self    :	str      ):
													a__:							Union[str, Any]									=ids_tensor([self.batch_size, self.seq_length]   ,							self.vocab_size      )

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

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

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

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

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


						def 	_lowerCamelCase      (			self    :	str      ):
													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 	_lowerCamelCase      (			self    :	List[Any]      ):
													a__:							str									=self.get_config()
													a__:							Optional[int]									=3_0_0
													return config


						def 	_lowerCamelCase      (			self    :	List[str]      ):
													(
													    (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,          
													):							Optional[int]									=self.prepare_config_and_inputs()

													a__:							Optional[Any]									=True
													a__:							str									=floats_tensor([self.batch_size, self.seq_length, self.hidden_size]      )
													a__:							int									=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 	_lowerCamelCase      (			self    :	List[str]   ,							_a    :	Tuple   ,							_a    :	Optional[Any]   ,							_a    :	List[str]   ,							_a    :	Optional[Any]   ,							_a    :	List[str]   ,							_a    :	Union[str, Any]   ,							_a    :	Dict      ):
													a__:							int									=YosoModel(config=snake_case_      )
													model.to(snake_case_      )
													model.eval()
													a__:							int									=model(snake_case_   ,							attention_mask=snake_case_   ,							token_type_ids=snake_case_      )
													a__:							List[Any]									=model(snake_case_   ,							token_type_ids=snake_case_      )
													a__:							Union[str, Any]									=model(snake_case_      )
													self.parent.assertEqual(result.last_hidden_state.shape   ,							(self.batch_size, self.seq_length, self.hidden_size)      )


						def 	_lowerCamelCase      (			self    :	Union[str, Any]   ,							_a    :	str   ,							_a    :	Tuple   ,							_a    :	Optional[Any]   ,							_a    :	Dict   ,							_a    :	int   ,							_a    :	Union[str, Any]   ,							_a    :	List[Any]   ,							_a    :	List[str]   ,							_a    :	Any   ,							):
													a__:							List[Any]									=True
													a__:							str									=YosoModel(snake_case_      )
													model.to(snake_case_      )
													model.eval()
													a__:							Optional[Any]									=model(
													    snake_case_   ,							attention_mask=snake_case_   ,							token_type_ids=snake_case_   ,							encoder_hidden_states=snake_case_   ,							encoder_attention_mask=snake_case_   ,							)
													a__:							List[Any]									=model(
													    snake_case_   ,							attention_mask=snake_case_   ,							token_type_ids=snake_case_   ,							encoder_hidden_states=snake_case_   ,							)
													a__:							List[str]									=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 	_lowerCamelCase      (			self    :	List[Any]   ,							_a    :	Dict   ,							_a    :	Optional[Any]   ,							_a    :	int   ,							_a    :	Optional[int]   ,							_a    :	Tuple   ,							_a    :	List[Any]   ,							_a    :	List[Any]      ):
													a__:							int									=YosoForMaskedLM(config=snake_case_      )
													model.to(snake_case_      )
													model.eval()
													a__:							Tuple									=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 	_lowerCamelCase      (			self    :	List[str]   ,							_a    :	Tuple   ,							_a    :	List[str]   ,							_a    :	str   ,							_a    :	str   ,							_a    :	List[str]   ,							_a    :	Optional[int]   ,							_a    :	List[Any]      ):
													a__:							Optional[Any]									=YosoForQuestionAnswering(config=snake_case_      )
													model.to(snake_case_      )
													model.eval()
													a__:							Optional[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 	_lowerCamelCase      (			self    :	Tuple   ,							_a    :	Optional[Any]   ,							_a    :	Tuple   ,							_a    :	Any   ,							_a    :	List[Any]   ,							_a    :	Any   ,							_a    :	List[str]   ,							_a    :	Optional[Any]      ):
													a__:							List[Any]									=self.num_labels
													a__:							str									=YosoForSequenceClassification(snake_case_      )
													model.to(snake_case_      )
													model.eval()
													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_labels)      )


						def 	_lowerCamelCase      (			self    :	Any   ,							_a    :	Optional[Any]   ,							_a    :	Any   ,							_a    :	Optional[Any]   ,							_a    :	Union[str, Any]   ,							_a    :	List[str]   ,							_a    :	Union[str, Any]   ,							_a    :	Dict      ):
													a__:							List[str]									=self.num_labels
													a__:							Dict									=YosoForTokenClassification(config=snake_case_      )
													model.to(snake_case_      )
													model.eval()
													a__:							List[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.seq_length, self.num_labels)      )


						def 	_lowerCamelCase      (			self    :	Tuple   ,							_a    :	str   ,							_a    :	int   ,							_a    :	Union[str, Any]   ,							_a    :	int   ,							_a    :	Any   ,							_a    :	Tuple   ,							_a    :	str      ):
													a__:							Tuple									=self.num_choices
													a__:							Any									=YosoForMultipleChoice(config=snake_case_      )
													model.to(snake_case_      )
													model.eval()
													a__:							Union[str, Any]									=input_ids.unsqueeze(1      ).expand(-1   ,							self.num_choices   ,							-1      ).contiguous()
													a__:							List[str]									=token_type_ids.unsqueeze(1      ).expand(-1   ,							self.num_choices   ,							-1      ).contiguous()
													a__:							List[Any]									=input_mask.unsqueeze(1      ).expand(-1   ,							self.num_choices   ,							-1      ).contiguous()
													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.num_choices)      )







						def 	_lowerCamelCase      (			self    :	List[str]      ):
													a__:							List[str]									=self.prepare_config_and_inputs()
													(
													    (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,      (
													    a__    
													)				,          
													):							List[Any]									=config_and_inputs
													a__:							Tuple									={"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
													return config, inputs_dict


@require_torch
class 						lowerCamelCase__			(		_a					,       _a					,       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 	_lowerCamelCase      (			self    :	Union[str, Any]      ):
													a__:							List[str]									=YosoModelTester(self      )
													a__:							Dict									=ConfigTester(self   ,							config_class=snake_case_   ,							hidden_size=3_7      )


						def 	_lowerCamelCase      (			self    :	Optional[int]      ):
													self.config_tester.run_common_tests()


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


						def 	_lowerCamelCase      (			self    :	Union[str, Any]      ):
													a__:							List[str]									=self.model_tester.prepare_config_and_inputs()
													for type in ["absolute", "relative_key", "relative_key_query"]:
																				a__:							List[str]									=type
																				self.model_tester.create_and_check_model(*snake_case_      )


						def 	_lowerCamelCase      (			self    :	int      ):
													a__:							Optional[int]									=self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_masked_lm(*snake_case_      )


						def 	_lowerCamelCase      (			self    :	int      ):
													a__:							Any									=self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_multiple_choice(*snake_case_      )


						def 	_lowerCamelCase      (			self    :	Optional[int]      ):
													a__:							Tuple									=self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_question_answering(*snake_case_      )


						def 	_lowerCamelCase      (			self    :	List[str]      ):
													a__:							List[Any]									=self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_sequence_classification(*snake_case_      )


						def 	_lowerCamelCase      (			self    :	Optional[Any]      ):
													a__:							Optional[int]									=self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_token_classification(*snake_case_      )


						@slow
						def 	_lowerCamelCase      (			self    :	int      ):
													for model_name in YOSO_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																				a__:							List[str]									=YosoModel.from_pretrained(snake_case_      )
																				self.assertIsNotNone(snake_case_      )







						def 	_lowerCamelCase      (			self    :	Union[str, Any]      ):
													return


@require_torch
class 						lowerCamelCase__			(		unittest.TestCase ):


						@slow
						def 	_lowerCamelCase      (			self    :	str      ):
													a__:							Dict									=YosoModel.from_pretrained("uw-madison/yoso-4096"      )
													a__:							int									=torch.tensor([[0, 1, 2, 3, 4, 5]]      )

													with torch.no_grad():
																				a__:							int									=model(snake_case_      )[0]

													a__:							str									=torch.Size((1, 6, 7_6_8)      )
													self.assertEqual(output.shape   ,							snake_case_      )

													a__:							List[Any]									=torch.tensor(
													    [[[-0.0_6_1_1, 0.1_2_4_2, 0.0_8_4_0], [0.0_2_8_0, -0.0_0_4_8, 0.1_1_2_5], [0.0_1_0_6, 0.0_2_2_6, 0.0_7_5_1]]]      )

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


						@slow
						def 	_lowerCamelCase      (			self    :	int      ):
													a__:							List[str]									=YosoForMaskedLM.from_pretrained("uw-madison/yoso-4096"      )
													a__:							Tuple									=torch.tensor([[0, 1, 2, 3, 4, 5]]      )

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

													a__:							Optional[Any]									=5_0_2_6_5

													a__:							Any									=torch.Size((1, 6, vocab_size)      )
													self.assertEqual(output.shape   ,							snake_case_      )

													a__:							str									=torch.tensor(
													    [[[-2.1_3_1_3, -3.7_2_8_5, -2.2_4_0_7], [-2.7_0_4_7, -3.3_3_1_4, -2.6_4_0_8], [0.0_6_2_9, -2.5_1_6_6, -0.3_3_5_6]]]      )

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







						@slow
						def 	_lowerCamelCase      (			self    :	List[Any]      ):
													a__:							Union[str, Any]									=YosoForMaskedLM.from_pretrained("uw-madison/yoso-4096"      )
													a__:							Union[str, Any]									=torch.arange(4_0_9_6      ).unsqueeze(0      )

													with torch.no_grad():
																				a__:							List[Any]									=model(snake_case_      )[0]

													a__:							Tuple									=5_0_2_6_5

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

													a__:							int									=torch.tensor(
													    [[[-2.3_9_1_4, -4.3_7_4_2, -5.0_9_5_6], [-4.0_9_8_8, -4.2_3_8_4, -7.0_4_0_6], [-3.1_4_2_7, -3.7_1_9_2, -6.6_8_0_0]]]      )

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













"""simple docstring"""





from math import gcd







def 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE = 1_20_00       )       ->						int:
    """simple docstring"""

    UpperCamelCase__								=     0
    for d in range(max_d + 1       ):
        for n in range(d // 3 + 1			,						(d + 1) // 2       ):
            if gcd(SCREAMING_SNAKE_CASE			,						SCREAMING_SNAKE_CASE       ) == 1:
                fractions_number += 1
    return fractions_number


if __name__ == "__main__":
  print(F"""{solution() = }""")




