
'''simple docstring'''







import os
import tempfile
import unittest

from transformers import NezhaConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
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 (
      MODEL_FOR_PRETRAINING_MAPPING,
      NezhaForMaskedLM,
      NezhaForMultipleChoice,
      NezhaForNextSentencePrediction,
      NezhaForPreTraining,
      NezhaForQuestionAnswering,
      NezhaForSequenceClassification,
      NezhaForTokenClassification,
      NezhaModel,
  )
  from transformers.models.nezha.modeling_nezha import NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST







class UpperCAmelCase__      :





  """simple docstring"""

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


     '''simple docstring'''






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


  def     __lowercase						(						self :	str			):


     '''simple docstring'''






     _a							:      Tuple     =  ids_tensor([self.batch_size, self.seq_length]				,self.vocab_size			)

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

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

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

     _a							:      str     =  self.get_config()

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


  def     __lowercase						(						self :	str			):


     '''simple docstring'''






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


  def     __lowercase						(						self :	Optional[Any]			):


     '''simple docstring'''






     (
         (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),          
     )							:      Union[str, Any]     =  self.prepare_config_and_inputs()

     _a							:      Any     =  True
     _a							:      Optional[Any]     =  floats_tensor([self.batch_size, self.seq_length, self.hidden_size]			)
     _a							:      List[str]     =  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     __lowercase						(						self :	Optional[Any]				,_a :	str				,_a :	List[str]				,_a :	int				,_a :	List[Any]				,_a :	int				,_a :	Optional[int]				,_a :	str			):


     '''simple docstring'''






     _a							:      List[Any]     =  NezhaModel(config=__a			)
     model.to(__a			)
     model.eval()
     _a							:      Optional[int]     =  model(__a				,attention_mask=__a				,token_type_ids=__a			)
     _a							:      str     =  model(__a				,token_type_ids=__a			)
     _a							:      List[Any]     =  model(__a			)
     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 :	Optional[int]				,_a :	Tuple				,_a :	Tuple				,_a :	int				,_a :	Union[str, Any]				,_a :	Dict				,_a :	Optional[int]				,_a :	Tuple				,_a :	Dict				,_a :	Tuple				,):


     '''simple docstring'''






     _a							:      Optional[Any]     =  True
     _a							:      List[Any]     =  NezhaModel(__a			)
     model.to(__a			)
     model.eval()
     _a							:      Tuple     =  model(
         __a				,attention_mask=__a				,token_type_ids=__a				,encoder_hidden_states=__a				,encoder_attention_mask=__a				,)
     _a							:      Any     =  model(
         __a				,attention_mask=__a				,token_type_ids=__a				,encoder_hidden_states=__a				,)
     _a							:      Optional[int]     =  model(__a				,attention_mask=__a				,token_type_ids=__a			)
     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 :	Optional[Any]				,_a :	Tuple				,_a :	int				,_a :	str				,_a :	List[Any]				,_a :	Tuple				,_a :	List[Any]				,_a :	int			):


     '''simple docstring'''






     _a							:      List[Any]     =  NezhaForMaskedLM(config=__a			)
     model.to(__a			)
     model.eval()
     _a							:      List[str]     =  model(__a				,attention_mask=__a				,token_type_ids=__a				,labels=__a			)
     self.parent.assertEqual(result.logits.shape				,(self.batch_size, self.seq_length, self.vocab_size)			)


  def     __lowercase						(						self :	List[Any]				,_a :	Union[str, Any]				,_a :	Dict				,_a :	List[Any]				,_a :	Union[str, Any]				,_a :	Any				,_a :	Dict				,_a :	Optional[Any]			):


     '''simple docstring'''






     _a							:      int     =  NezhaForNextSentencePrediction(config=__a			)
     model.to(__a			)
     model.eval()
     _a							:      Dict     =  model(
         __a				,attention_mask=__a				,token_type_ids=__a				,labels=__a				,)
     self.parent.assertEqual(result.logits.shape				,(self.batch_size, 2)			)


  def     __lowercase						(						self :	Optional[Any]				,_a :	Dict				,_a :	Dict				,_a :	Union[str, Any]				,_a :	Optional[int]				,_a :	str				,_a :	Tuple				,_a :	Union[str, Any]			):


     '''simple docstring'''






     _a							:      str     =  NezhaForPreTraining(config=__a			)
     model.to(__a			)
     model.eval()
     _a							:      List[str]     =  model(
         __a				,attention_mask=__a				,token_type_ids=__a				,labels=__a				,next_sentence_label=__a				,)
     self.parent.assertEqual(result.prediction_logits.shape				,(self.batch_size, self.seq_length, self.vocab_size)			)
     self.parent.assertEqual(result.seq_relationship_logits.shape				,(self.batch_size, 2)			)


  def     __lowercase						(						self :	Optional[Any]				,_a :	List[str]				,_a :	Optional[Any]				,_a :	Any				,_a :	Any				,_a :	int				,_a :	List[str]				,_a :	Any			):


     '''simple docstring'''






     _a							:      int     =  NezhaForQuestionAnswering(config=__a			)
     model.to(__a			)
     model.eval()
     _a							:      Optional[Any]     =  model(
         __a				,attention_mask=__a				,token_type_ids=__a				,start_positions=__a				,end_positions=__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     __lowercase						(						self :	Optional[int]				,_a :	int				,_a :	List[str]				,_a :	str				,_a :	Optional[Any]				,_a :	Union[str, Any]				,_a :	int				,_a :	str			):


     '''simple docstring'''






     _a							:      Dict     =  self.num_labels
     _a							:      Union[str, Any]     =  NezhaForSequenceClassification(__a			)
     model.to(__a			)
     model.eval()
     _a							:      Tuple     =  model(__a				,attention_mask=__a				,token_type_ids=__a				,labels=__a			)
     self.parent.assertEqual(result.logits.shape				,(self.batch_size, self.num_labels)			)


  def     __lowercase						(						self :	List[Any]				,_a :	int				,_a :	Any				,_a :	Optional[int]				,_a :	int				,_a :	int				,_a :	Union[str, Any]				,_a :	str			):


     '''simple docstring'''






     _a							:      List[str]     =  self.num_labels
     _a							:      Optional[Any]     =  NezhaForTokenClassification(config=__a			)
     model.to(__a			)
     model.eval()
     _a							:      Tuple     =  model(__a				,attention_mask=__a				,token_type_ids=__a				,labels=__a			)
     self.parent.assertEqual(result.logits.shape				,(self.batch_size, self.seq_length, self.num_labels)			)


  def     __lowercase						(						self :	Any				,_a :	Union[str, Any]				,_a :	List[Any]				,_a :	List[str]				,_a :	List[str]				,_a :	Any				,_a :	Union[str, Any]				,_a :	str			):


     '''simple docstring'''






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


  def     __lowercase						(						self :	Optional[int]			):


     '''simple docstring'''






     _a							:      Optional[int]     =  self.prepare_config_and_inputs()
     (
         (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),          
     )							:      List[Any]     =  config_and_inputs
     _a							:      Dict     =  {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
     return config, inputs_dict







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





  """simple docstring"""

  __UpperCAmelCase							:							List[Any]    					=   (
      (
          NezhaModel,
          NezhaForMaskedLM,
          NezhaForMultipleChoice,
          NezhaForNextSentencePrediction,
          NezhaForPreTraining,
          NezhaForQuestionAnswering,
          NezhaForSequenceClassification,
          NezhaForTokenClassification,
      )
      if is_torch_available()
      else ()
  )
  __UpperCAmelCase							:							List[Any]    					=   (
      {
          '''feature-extraction''': NezhaModel,
          '''fill-mask''': NezhaForMaskedLM,
          '''question-answering''': NezhaForQuestionAnswering,
          '''text-classification''': NezhaForSequenceClassification,
          '''token-classification''': NezhaForTokenClassification,
          '''zero-shot''': NezhaForSequenceClassification,
      }
      if is_torch_available()
      else {}
  )
  __UpperCAmelCase							:							int    					=   True


  def     __lowercase						(						self :	str				,_a :	Any				,_a :	Any				,_a :	Optional[int]=False			):


     '''simple docstring'''






     _a							:      Union[str, Any]     =  super()._prepare_for_class(__a				,__a				,return_labels=__a			)

     if return_labels:
        if model_class in get_values(__a			):
           _a							:      List[str]     =  torch.zeros(
               (self.model_tester.batch_size, self.model_tester.seq_length)				,dtype=torch.long				,device=__a			)
           _a							:      Dict     =  torch.zeros(
               self.model_tester.batch_size				,dtype=torch.long				,device=__a			)
     return inputs_dict


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


     '''simple docstring'''






     _a							:      Tuple     =  NezhaModelTester(self			)
     _a							:      str     =  ConfigTester(self				,config_class=__a				,hidden_size=37			)


  def     __lowercase						(						self :	Any			):


     '''simple docstring'''






     self.config_tester.run_common_tests()


  def     __lowercase						(						self :	int			):


     '''simple docstring'''






     _a							:      Tuple     =  self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_model(*__a			)


  def     __lowercase						(						self :	Any			):


     '''simple docstring'''






     _a							:      int     =  self.model_tester.prepare_config_and_inputs_for_decoder()
     self.model_tester.create_and_check_model_as_decoder(*__a			)


  def     __lowercase						(						self :	List[str]			):


     '''simple docstring'''






     (
         (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),    (
         _a      
     ),          
     )							:      Optional[Any]     =  self.model_tester.prepare_config_and_inputs_for_decoder()

     _a							:      str     =  None

     self.model_tester.create_and_check_model_as_decoder(
         __a				,__a				,__a				,__a				,__a				,__a				,__a				,__a				,__a				,)


  def     __lowercase						(						self :	List[Any]			):


     '''simple docstring'''






     _a							:      Any     =  self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_masked_lm(*__a			)


  def     __lowercase						(						self :	List[str]			):


     '''simple docstring'''






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


  def     __lowercase						(						self :	Optional[int]			):


     '''simple docstring'''






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


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


     '''simple docstring'''






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


  def     __lowercase						(						self :	Optional[Any]			):


     '''simple docstring'''






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


  def     __lowercase						(						self :	Dict			):


     '''simple docstring'''






     _a							:      Tuple     =  self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_sequence_classification(*__a			)


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


     '''simple docstring'''






     _a							:      str     =  self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_token_classification(*__a			)


  @slow
  def     __lowercase						(						self :	Union[str, Any]			):


     '''simple docstring'''






     for model_name in NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
        _a							:      List[str]     =  NezhaModel.from_pretrained(__a			)
        self.assertIsNotNone(__a			)


  @slow
  @require_torch_gpu
  def     __lowercase						(						self :	Optional[int]			):


     '''simple docstring'''






     _a,    _a							:      List[str]     =  self.model_tester.prepare_config_and_inputs_for_common()
     for model_class in self.all_model_classes:
        # NezhaForMultipleChoice behaves incorrectly in JIT environments.
        if model_class == NezhaForMultipleChoice:
           return

        _a							:      int     =  True
        _a							:      Dict     =  model_class(config=__a			)

        _a							:      str     =  self._prepare_for_class(__a				,__a			)
        _a							:      int     =  torch.jit.trace(
            __a				,(inputs_dict['input_ids'].to('cpu'			), inputs_dict['attention_mask'].to('cpu'			))			)

        with tempfile.TemporaryDirectory() as tmp:
           torch.jit.save(__a				,os.path.join(__a				,'bert.pt'			)			)
           _a							:      str     =  torch.jit.load(os.path.join(__a				,'bert.pt'			)				,map_location=__a			)
           loaded(inputs_dict['input_ids'].to(__a			)				,inputs_dict['attention_mask'].to(__a			)			)







@require_torch
class UpperCAmelCase__      (					unittest.TestCase      ):





  """simple docstring"""

  @slow
  def     __lowercase						(						self :	str			):


     '''simple docstring'''






     _a							:      Union[str, Any]     =  NezhaModel.from_pretrained('sijunhe/nezha-cn-base'			)
     _a							:      str     =  torch.tensor([[0, 1, 2, 3, 4, 5]]			)
     _a							:      str     =  torch.tensor([[0, 1, 1, 1, 1, 1]]			)
     with torch.no_grad():
        _a							:      Union[str, Any]     =  model(__a				,attention_mask=__a			)[0]
     _a							:      Any     =  torch.Size((1, 6, 768)			)
     self.assertEqual(output.shape				,__a			)
     _a							:      Optional[Any]     =  torch.tensor([[[0.0685, 0.2441, 0.1102], [0.0600, 0.1906, 0.1349], [0.0221, 0.0819, 0.0586]]]			)

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


  @slow
  def     __lowercase						(						self :	Any			):


     '''simple docstring'''






     _a							:      Tuple     =  NezhaForMaskedLM.from_pretrained('sijunhe/nezha-cn-base'			)
     _a							:      Tuple     =  torch.tensor([[0, 1, 2, 3, 4, 5]]			)
     _a							:      Optional[int]     =  torch.tensor([[1, 1, 1, 1, 1, 1]]			)
     with torch.no_grad():
        _a							:      Optional[Any]     =  model(__a				,attention_mask=__a			)[0]
     _a							:      Optional[Any]     =  torch.Size((1, 6, 2_1128)			)
     self.assertEqual(output.shape				,__a			)
     _a							:      List[Any]     =  torch.tensor(
         [[-2.7939, -1.7902, -2.2189], [-2.8585, -1.8908, -2.3723], [-2.6499, -1.7750, -2.2558]]			)

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




'''simple docstring'''


import importlib
import os
import sys


# This is required to make the module import works (when the python process is running from the root of the repo)
sys.path.append(".")





def    lowerCAmelCase       (		UpperCamelCase__					: Dict							):


	"""simple docstring"""
	__UpperCAmelCase      					=      test_file.split(os.path.sep							)
	if components[0:2] != ["tests", "models"]:
		raise ValueError(
		    '''`test_file` should start with `tests/models/` (with `/` being the OS specific path separator). Got '''
		    f"""{test_file} instead."""							)
	__UpperCAmelCase      					=      components[-1]
	if not test_fn.endswith('''py'''							):
		raise ValueError(f"""`test_file` should be a python file. Got {test_fn} instead."""							)
	if not test_fn.startswith('''test_modeling_'''							):
		raise ValueError(
		    f"""`test_file` should point to a file name of the form `test_modeling_*.py`. Got {test_fn} instead."""							)

	__UpperCAmelCase      					=      components[:-1] + [test_fn.replace('''.py'''     ,       ''''''							)]
	__UpperCAmelCase      					=      '''.'''.join(UpperCamelCase__							)

	return test_module_path





def    lowerCAmelCase       (		UpperCamelCase__					: int							):


	"""simple docstring"""
	__UpperCAmelCase      					=      get_module_path(UpperCamelCase__							)
	__UpperCAmelCase      					=      importlib.import_module(UpperCamelCase__							)

	return test_module





def    lowerCAmelCase       (		UpperCamelCase__					: Tuple							):


	"""simple docstring"""
	__UpperCAmelCase      					=      []
	__UpperCAmelCase      					=      get_test_module(UpperCamelCase__							)
	for attr in dir(UpperCamelCase__							):
		if attr.endswith('''ModelTester'''							):
			tester_classes.append(getattr(UpperCamelCase__     ,       UpperCamelCase__							)							)

    # sort with class names
	return sorted(UpperCamelCase__     ,       key=lambda UpperCamelCase__							: x.__name__							)





def    lowerCAmelCase       (		UpperCamelCase__					: List[Any]							):


	"""simple docstring"""
	__UpperCAmelCase      					=      []
	__UpperCAmelCase      					=      get_test_module(UpperCamelCase__							)
	for attr in dir(UpperCamelCase__							):
		__UpperCAmelCase      					=      getattr(UpperCamelCase__     ,       UpperCamelCase__							)
		# (TF/Flax)ModelTesterMixin is also an attribute in specific model test module. Let's exclude them by checking
		# `all_model_classes` is not empty (which also excludes other special classes).
		__UpperCAmelCase      					=      getattr(UpperCamelCase__     ,       '''all_model_classes'''     ,       []							)
		if len(UpperCamelCase__							) > 0:
			test_classes.append(UpperCamelCase__							)

    # sort with class names
	return sorted(UpperCamelCase__     ,       key=lambda UpperCamelCase__							: x.__name__							)





def    lowerCAmelCase       (		UpperCamelCase__					: str							):


	"""simple docstring"""
	__UpperCAmelCase      					=      get_test_classes(UpperCamelCase__							)
	__UpperCAmelCase      					=      set()
	for test_class in test_classes:
		model_classes.update(test_class.all_model_classes							)

	# sort with class names
	return sorted(UpperCamelCase__     ,       key=lambda UpperCamelCase__							: x.__name__							)





def    lowerCAmelCase       (		UpperCamelCase__					: Any							):


	"""simple docstring"""
	__UpperCAmelCase      					=      test_class()
	if hasattr(UpperCamelCase__     ,       '''setUp'''							):
		test.setUp()

	__UpperCAmelCase      					=      None
	if hasattr(UpperCamelCase__     ,       '''model_tester'''							):
		# `(TF/Flax)ModelTesterMixin` has this attribute default to `None`. Let's skip this case.
		if test.model_tester is not None:
			__UpperCAmelCase      					=      test.model_tester.__class__

	return model_tester





def    lowerCAmelCase       (		UpperCamelCase__					: Dict     ,       UpperCamelCase__					: int							):


	"""simple docstring"""
	__UpperCAmelCase      					=      get_test_classes(UpperCamelCase__							)

	__UpperCAmelCase      					=      []
	for test_class in test_classes:
		if model_class in test_class.all_model_classes:
			target_test_classes.append(UpperCamelCase__							)

    # sort with class names
	return sorted(UpperCamelCase__     ,       key=lambda UpperCamelCase__							: x.__name__							)





def    lowerCAmelCase       (		UpperCamelCase__					: Tuple     ,       UpperCamelCase__					: Any							):


	"""simple docstring"""
	__UpperCAmelCase      					=      get_test_classes_for_model(UpperCamelCase__     ,       UpperCamelCase__							)

	__UpperCAmelCase      					=      []
	for test_class in test_classes:
		__UpperCAmelCase      					=      get_model_tester_from_test_class(UpperCamelCase__							)
		if tester_class is not None:
			tester_classes.append(UpperCamelCase__							)

    # sort with class names
	return sorted(UpperCamelCase__     ,       key=lambda UpperCamelCase__							: x.__name__							)





def    lowerCAmelCase       (		UpperCamelCase__					: int							):


	"""simple docstring"""
	__UpperCAmelCase      					=      get_test_classes(UpperCamelCase__							)
	__UpperCAmelCase      					=      {test_class: get_model_tester_from_test_class(UpperCamelCase__							) for test_class in test_classes}
	return test_tester_mapping





def    lowerCAmelCase       (		UpperCamelCase__					: str							):


	"""simple docstring"""
	__UpperCAmelCase      					=      get_model_classes(UpperCamelCase__							)
	__UpperCAmelCase      					=      {
	    model_class: get_test_classes_for_model(UpperCamelCase__     ,       UpperCamelCase__							) for model_class in model_classes
	}
	return model_test_mapping





def    lowerCAmelCase       (		UpperCamelCase__					: Optional[int]							):


	"""simple docstring"""
	__UpperCAmelCase      					=      get_model_classes(UpperCamelCase__							)
	__UpperCAmelCase      					=      {
	    model_class: get_tester_classes_for_model(UpperCamelCase__     ,       UpperCamelCase__							) for model_class in model_classes
	}
	return model_to_tester_mapping





def    lowerCAmelCase       (		UpperCamelCase__					: Tuple							):


	"""simple docstring"""
	if isinstance(UpperCamelCase__     ,       UpperCamelCase__							):
		return o
	elif isinstance(UpperCamelCase__     ,       UpperCamelCase__							):
		return o.__name__
	elif isinstance(UpperCamelCase__     ,       (list, tuple)							):
		return [to_json(UpperCamelCase__							) for x in o]
	elif isinstance(UpperCamelCase__     ,       UpperCamelCase__							):
		return {to_json(UpperCamelCase__							): to_json(UpperCamelCase__							) for k, v in o.items()}
	else:
		return o
