
'''simple docstring'''





import math



class 			lowerCAmelCase__ :



  '''simple docstring'''






  def __init__(self	:			Optional[Any]						,			lowerCAmelCase_	:			int						,			lowerCAmelCase_	:			int						,			lowerCAmelCase_	:			int						,			lowerCAmelCase_	:			Optional[Any]     ) ->							Any:
        snake_case_    							=				x
        snake_case_    							=				y
        snake_case_    							=				step_size
        snake_case_    							=				function_to_optimize

  def 		_lowerCamelCase						(self	:			Optional[int]     ) ->							int:
        return self.function(self.x						,			self.y     )

  def 		_lowerCamelCase						(self	:			int     ) ->							Tuple:
        snake_case_    							=				self.step_size
        return [
            SearchProblem(lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			self.function     )
            for x, y in (
                (self.x - step_size, self.y - step_size),
                (self.x - step_size, self.y),
                (self.x - step_size, self.y + step_size),
                (self.x, self.y - step_size),
                (self.x, self.y + step_size),
                (self.x + step_size, self.y - step_size),
                (self.x + step_size, self.y),
                (self.x + step_size, self.y + step_size),
            )
        ]

  def __hash__(self	:			Optional[int]     ) ->							Union[str, Any]:
        return hash(str(self     )     )

  def __eq__(self	:			List[str]						,			lowerCAmelCase_	:			str     ) ->							Dict:
        if isinstance(lowerCAmelCase_						,			lowerCAmelCase_     ):
              return hash(str(self     )     ) == hash(str(lowerCAmelCase_     )     )
        return False


  def __str__(self	:			Tuple     ) ->							str:
        return f'''x: {self.x} y: {self.y}'''

def 	snake_case_							(				_a  :				Tuple			,       _a  :				bool = True			,       _a  :				float = math.inf			,       _a  :				float = -math.inf			,       _a  :				float = math.inf			,       _a  :				float = -math.inf			,       _a  :				bool = False			,       _a  :				int = 10_000			,       ):
      snake_case_    							=				search_prob
      snake_case_    							=				[]  # list to store the current score at each iteration
      snake_case_    							=				0
      snake_case_    							=				False
      snake_case_    							=				set()
      while not solution_found and iterations < max_iter:
            visited.add(_a      )
            iterations += 1
            snake_case_    							=				current_state.score()
            scores.append(_a      )
            snake_case_    							=				current_state.get_neighbors()
            snake_case_    							=				-math.inf
            snake_case_    							=				math.inf
            snake_case_    							=				None  # to hold the next best neighbor
            for neighbor in neighbors:
                  if neighbor in visited:
                        continue  # do not want to visit the same state again
                  if (
                      neighbor.x > max_x
                      or neighbor.x < min_x
                      or neighbor.y > max_y
                      or neighbor.y < min_y
                  ):
                        continue  # neighbor outside our bounds
                  snake_case_    							=				neighbor.score() - current_score
                  if find_max:  # finding max
                        # going to direction with greatest ascent
                        if change > max_change and change > 0:
                              snake_case_    							=				change
                              snake_case_    							=				neighbor
                  else:  # finding min
                        # to direction with greatest descent
                        if change < min_change and change < 0:
                              snake_case_    							=				change
                              snake_case_    							=				neighbor
            if next_state is not None:
                  # we found at least one neighbor which improved the current state
                  snake_case_    							=				next_state
            else:
                  # since we have no neighbor that improves the solution we stop the search
                  snake_case_    							=				True

      if visualization:
            from matplotlib import pyplot as plt

            plt.plot(range(_a      )			,       _a      )
            plt.xlabel("Iterations"      )
            plt.ylabel("Function values"      )
            plt.show()

      return current_state


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     def 	snake_case_							(				_a  :				Optional[Any]			,       _a  :				Dict      ):
           return (x**2) + (y**2)

     # starting the problem with initial coordinates (3, 4)
     A							     = SearchProblem(x=3, y=4, step_size=1, function_to_optimize=test_fa)
     A							     = hill_climbing(prob, find_max=False)
     print(
         "The minimum score for f(x, y) = x^2 + y^2 found via hill climbing: "
         F"""{local_min.score()}"""
     )

     # starting the problem with initial coordinates (12, 47)
     A							     = SearchProblem(x=1_2, y=4_7, step_size=1, function_to_optimize=test_fa)
     A							     = hill_climbing(
         prob, find_max=False, max_x=1_0_0, min_x=5, max_y=5_0, min_y=-5, visualization=True
     )
     print(
         "The minimum score for f(x, y) = x^2 + y^2 with the domain 100 > x > 5 "
         F"""and 50 > y > - 5 found via hill climbing: {local_min.score()}"""
     )
     def 	snake_case_							(				_a  :				Optional[Any]			,       _a  :				Tuple      ):
           return (3 * x**2) - (6 * y)

     A							     = SearchProblem(x=3, y=4, step_size=1, function_to_optimize=test_fa)
     A							     = hill_climbing(prob, find_max=True)




     print(
         "The maximum score for f(x, y) = x^2 + y^2 found via hill climbing: "
         F"""{local_min.score()}"""
     )







'''simple docstring'''


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







  '''simple docstring'''

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







       '''simple docstring'''



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



  def 					_snake_case     ( self				:							Optional[int]	)			->		List[Any]:







       '''simple docstring'''



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

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

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

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

       A:		List[str]          =		self.get_config()

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



  def 					_snake_case     ( self				:							Union[str, Any]	)			->		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=SCREAMING_SNAKE_CASE_					,  initializer_range=self.initializer_range					,  )



  def 					_snake_case     ( self				:							Optional[Any]	)			->		Tuple:







       '''simple docstring'''



       A:		str          =		self.get_config()
       A:		Tuple          =		3_00
       return config



  def 					_snake_case     ( self				:							Union[str, Any]	)			->		Optional[Any]:







       '''simple docstring'''



       (
           (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    
       ):		Optional[int]          =		self.prepare_config_and_inputs()

       A:		Any          =		True
       A:		Tuple          =		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 					_snake_case     ( self				:							int					,  SCREAMING_SNAKE_CASE_				:							str					,  SCREAMING_SNAKE_CASE_				:							List[str]					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]					,  SCREAMING_SNAKE_CASE_				:							int					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]	)			->		Optional[Any]:







       '''simple docstring'''



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



  def 					_snake_case     ( self				:							Optional[int]					,  SCREAMING_SNAKE_CASE_				:							List[str]					,  SCREAMING_SNAKE_CASE_				:							Any					,  SCREAMING_SNAKE_CASE_				:							Dict					,  SCREAMING_SNAKE_CASE_				:							List[str]					,  SCREAMING_SNAKE_CASE_				:							int					,  SCREAMING_SNAKE_CASE_				:							Optional[int]					,  SCREAMING_SNAKE_CASE_				:							int					,  SCREAMING_SNAKE_CASE_				:							Optional[Any]					,  SCREAMING_SNAKE_CASE_				:							List[Any]					,  )			->		List[Any]:







       '''simple docstring'''



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



  def 					_snake_case     ( self				:							Optional[int]					,  SCREAMING_SNAKE_CASE_				:							str					,  SCREAMING_SNAKE_CASE_				:							Tuple					,  SCREAMING_SNAKE_CASE_				:							Dict					,  SCREAMING_SNAKE_CASE_				:							Dict					,  SCREAMING_SNAKE_CASE_				:							Optional[Any]					,  SCREAMING_SNAKE_CASE_				:							str					,  SCREAMING_SNAKE_CASE_				:							Tuple	)			->		Union[str, Any]:







       '''simple docstring'''



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



  def 					_snake_case     ( self				:							Dict					,  SCREAMING_SNAKE_CASE_				:							Optional[Any]					,  SCREAMING_SNAKE_CASE_				:							Any					,  SCREAMING_SNAKE_CASE_				:							Optional[int]					,  SCREAMING_SNAKE_CASE_				:							Tuple					,  SCREAMING_SNAKE_CASE_				:							Dict					,  SCREAMING_SNAKE_CASE_				:							List[Any]					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]	)			->		int:







       '''simple docstring'''



       A:		Optional[int]          =		YosoForQuestionAnswering(config=SCREAMING_SNAKE_CASE_	)
       model.to(SCREAMING_SNAKE_CASE_	)
       model.eval()
       A:		Dict          =		model(
           SCREAMING_SNAKE_CASE_					,  attention_mask=SCREAMING_SNAKE_CASE_					,  token_type_ids=SCREAMING_SNAKE_CASE_					,  start_positions=SCREAMING_SNAKE_CASE_					,  end_positions=SCREAMING_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 					_snake_case     ( self				:							Optional[int]					,  SCREAMING_SNAKE_CASE_				:							List[Any]					,  SCREAMING_SNAKE_CASE_				:							List[str]					,  SCREAMING_SNAKE_CASE_				:							Tuple					,  SCREAMING_SNAKE_CASE_				:							Dict					,  SCREAMING_SNAKE_CASE_				:							Dict					,  SCREAMING_SNAKE_CASE_				:							Tuple					,  SCREAMING_SNAKE_CASE_				:							Dict	)			->		List[Any]:







       '''simple docstring'''



       A:		str          =		self.num_labels
       A:		int          =		YosoForSequenceClassification(SCREAMING_SNAKE_CASE_	)
       model.to(SCREAMING_SNAKE_CASE_	)
       model.eval()
       A:		Any          =		model(SCREAMING_SNAKE_CASE_					,  attention_mask=SCREAMING_SNAKE_CASE_					,  token_type_ids=SCREAMING_SNAKE_CASE_					,  labels=SCREAMING_SNAKE_CASE_	)
       self.parent.assertEqual(result.logits.shape					,  (self.batch_size, self.num_labels)	)



  def 					_snake_case     ( self				:							Dict					,  SCREAMING_SNAKE_CASE_				:							Any					,  SCREAMING_SNAKE_CASE_				:							Dict					,  SCREAMING_SNAKE_CASE_				:							List[str]					,  SCREAMING_SNAKE_CASE_				:							Any					,  SCREAMING_SNAKE_CASE_				:							str					,  SCREAMING_SNAKE_CASE_				:							Dict					,  SCREAMING_SNAKE_CASE_				:							Dict	)			->		Optional[Any]:







       '''simple docstring'''



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



  def 					_snake_case     ( self				:							Union[str, Any]					,  SCREAMING_SNAKE_CASE_				:							List[str]					,  SCREAMING_SNAKE_CASE_				:							str					,  SCREAMING_SNAKE_CASE_				:							Optional[int]					,  SCREAMING_SNAKE_CASE_				:							Optional[Any]					,  SCREAMING_SNAKE_CASE_				:							Any					,  SCREAMING_SNAKE_CASE_				:							str					,  SCREAMING_SNAKE_CASE_				:							Optional[Any]	)			->		Any:







       '''simple docstring'''



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




  def 					_snake_case     ( self				:							int	)			->		Optional[int]:







       '''simple docstring'''



       A:		List[Any]          =		self.prepare_config_and_inputs()
       (
           (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    (
           A
       )     ,    
       ):		Optional[int]          =		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 						lowerCAmelCase_	(       UpperCAmelCase_       ,					UpperCAmelCase_       ,					unittest.TestCase							):







  '''simple docstring'''

  UpperCamelCase_			:      List[str]										=				(
      (
          YosoModel,
          YosoForMaskedLM,
          YosoForMultipleChoice,
          YosoForQuestionAnswering,
          YosoForSequenceClassification,
          YosoForTokenClassification,
      )
      if is_torch_available()
      else ()
  )
  UpperCamelCase_			:      Tuple										=				False
  UpperCamelCase_			:      Tuple										=				False
  UpperCamelCase_			:      List[str]										=				False

  UpperCamelCase_			:      List[str]										=				()
  UpperCamelCase_			:      Optional[int]										=				(
      {
          """feature-extraction""": YosoModel,
          """fill-mask""": YosoForMaskedLM,
          """question-answering""": YosoForQuestionAnswering,
          """text-classification""": YosoForSequenceClassification,
          """token-classification""": YosoForTokenClassification,
          """zero-shot""": YosoForSequenceClassification,
      }
      if is_torch_available()
      else {}
  )



  def 					_snake_case     ( self				:							Dict	)			->		Any:







       '''simple docstring'''



       A:		Tuple          =		YosoModelTester(self	)
       A:		str          =		ConfigTester(self					,  config_class=SCREAMING_SNAKE_CASE_					,  hidden_size=37	)



  def 					_snake_case     ( self				:							Union[str, Any]	)			->		Union[str, Any]:







       '''simple docstring'''



       self.config_tester.run_common_tests()



  def 					_snake_case     ( self				:							str	)			->		Optional[Any]:







       '''simple docstring'''



       A:		int          =		self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_	)



  def 					_snake_case     ( self				:							Union[str, Any]	)			->		int:







       '''simple docstring'''



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



  def 					_snake_case     ( self				:							Tuple	)			->		Optional[int]:







       '''simple docstring'''



       A:		List[str]          =		self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE_	)



  def 					_snake_case     ( self				:							List[Any]	)			->		str:







       '''simple docstring'''



       A:		str          =		self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE_	)



  def 					_snake_case     ( self				:							List[str]	)			->		str:







       '''simple docstring'''



       A:		Tuple          =		self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE_	)



  def 					_snake_case     ( self				:							Tuple	)			->		Dict:







       '''simple docstring'''



       A:		int          =		self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE_	)



  def 					_snake_case     ( self				:							Dict	)			->		Dict:







       '''simple docstring'''



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



  @slow
  def 					_snake_case     ( self				:							int	)			->		int:







       '''simple docstring'''



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




  def 					_snake_case     ( self				:							Optional[Any]	)			->		Any:







       '''simple docstring'''



       return






@require_torch
class 						lowerCAmelCase_	(       unittest.TestCase							):







  '''simple docstring'''

  @slow
  def 					_snake_case     ( self				:							Union[str, Any]	)			->		Union[str, Any]:







       '''simple docstring'''



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

       with torch.no_grad():
            A:		Union[str, Any]          =		model(SCREAMING_SNAKE_CASE_	)[0]

       A:		List[str]          =		torch.Size((1, 6, 7_68)	)
       self.assertEqual(output.shape					,  SCREAMING_SNAKE_CASE_	)

       A:		int          =		torch.tensor(
           [[[-0.0611, 0.1242, 0.0840], [0.0280, -0.0048, 0.1125], [0.0106, 0.0226, 0.0751]]]	)

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



  @slow
  def 					_snake_case     ( self				:							int	)			->		Tuple:







       '''simple docstring'''



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

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

       A:		Optional[int]          =		5_02_65

       A:		List[str]          =		torch.Size((1, 6, vocab_size)	)
       self.assertEqual(output.shape					,  SCREAMING_SNAKE_CASE_	)

       A:		Dict          =		torch.tensor(
           [[[-2.1313, -3.7285, -2.2407], [-2.7047, -3.3314, -2.6408], [0.0629, -2.5166, -0.3356]]]	)

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




  @slow
  def 					_snake_case     ( self				:							Dict	)			->		Tuple:







       '''simple docstring'''



       A:		List[str]          =		YosoForMaskedLM.from_pretrained('''uw-madison/yoso-4096'''	)
       A:		Optional[int]          =		torch.arange(40_96	).unsqueeze(0	)

       with torch.no_grad():
            A:		int          =		model(SCREAMING_SNAKE_CASE_	)[0]

       A:		Optional[int]          =		5_02_65

       A:		Dict          =		torch.Size((1, 40_96, vocab_size)	)
       self.assertEqual(output.shape					,  SCREAMING_SNAKE_CASE_	)

       A:		Optional[int]          =		torch.tensor(
           [[[-2.3914, -4.3742, -5.0956], [-4.0988, -4.2384, -7.0406], [-3.1427, -3.7192, -6.6800]]]	)

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






