

'''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 							_snake_case	:
   def __init__(	self     : Dict       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : int=13       ,SCREAMING_SNAKE_CASE__     : Any=7       ,SCREAMING_SNAKE_CASE__     : List[str]=True       ,SCREAMING_SNAKE_CASE__     : int=True       ,SCREAMING_SNAKE_CASE__     : Dict=True       ,SCREAMING_SNAKE_CASE__     : Tuple=True       ,SCREAMING_SNAKE_CASE__     : Tuple=99       ,SCREAMING_SNAKE_CASE__     : Optional[int]=32       ,SCREAMING_SNAKE_CASE__     : List[str]=5       ,SCREAMING_SNAKE_CASE__     : Any=4       ,SCREAMING_SNAKE_CASE__     : int=37       ,SCREAMING_SNAKE_CASE__     : str="gelu"       ,SCREAMING_SNAKE_CASE__     : List[str]=0.1       ,SCREAMING_SNAKE_CASE__     : Optional[int]=0.1       ,SCREAMING_SNAKE_CASE__     : Tuple=512       ,SCREAMING_SNAKE_CASE__     : int=16       ,SCREAMING_SNAKE_CASE__     : List[str]=2       ,SCREAMING_SNAKE_CASE__     : Tuple=0.02       ,SCREAMING_SNAKE_CASE__     : int=3       ,SCREAMING_SNAKE_CASE__     : Optional[int]=4       ,SCREAMING_SNAKE_CASE__     : Dict=None       ,):
     SCREAMING_SNAKE_CASE:List[Any]   =   parent
     SCREAMING_SNAKE_CASE:List[Any]   =   batch_size
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   seq_length
     SCREAMING_SNAKE_CASE:Optional[int]   =   is_training
     SCREAMING_SNAKE_CASE:Tuple   =   use_input_mask
     SCREAMING_SNAKE_CASE:Optional[int]   =   use_token_type_ids
     SCREAMING_SNAKE_CASE:Any   =   use_labels
     SCREAMING_SNAKE_CASE:Tuple   =   vocab_size
     SCREAMING_SNAKE_CASE:List[str]   =   hidden_size
     SCREAMING_SNAKE_CASE:Optional[Any]   =   num_hidden_layers
     SCREAMING_SNAKE_CASE:Optional[int]   =   num_attention_heads
     SCREAMING_SNAKE_CASE:Any   =   intermediate_size
     SCREAMING_SNAKE_CASE:Optional[Any]   =   hidden_act
     SCREAMING_SNAKE_CASE:Optional[int]   =   hidden_dropout_prob
     SCREAMING_SNAKE_CASE:List[str]   =   attention_probs_dropout_prob
     SCREAMING_SNAKE_CASE:Optional[Any]   =   max_position_embeddings
     SCREAMING_SNAKE_CASE:Dict   =   type_vocab_size
     SCREAMING_SNAKE_CASE:Optional[int]   =   type_sequence_label_size
     SCREAMING_SNAKE_CASE:int   =   initializer_range
     SCREAMING_SNAKE_CASE:Dict   =   num_labels
     SCREAMING_SNAKE_CASE:List[Any]   =   num_choices
     SCREAMING_SNAKE_CASE:List[Any]   =   scope
   def       __UpperCamelCase  (	self     : int							):
     SCREAMING_SNAKE_CASE:List[str]   =   ids_tensor([self.batch_size, self.seq_length]       ,self.vocab_size							)

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

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

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

     SCREAMING_SNAKE_CASE:Optional[Any]   =   self.get_config()

     return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
   def       __UpperCamelCase  (	self     : List[Any]							):
     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       __UpperCamelCase  (	self     : Union[str, Any]							):
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   self.get_config()
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   300
     return config
   def       __UpperCamelCase  (	self     : Tuple							):
     (
         (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      
     ):List[Any]   =   self.prepare_config_and_inputs()

     SCREAMING_SNAKE_CASE:List[Any]   =   True
     SCREAMING_SNAKE_CASE:int   =   floats_tensor([self.batch_size, self.seq_length, self.hidden_size]							)
     SCREAMING_SNAKE_CASE: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       __UpperCamelCase  (	self     : List[Any]       ,SCREAMING_SNAKE_CASE__     : Optional[int]       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : Any							):
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   YosoModel(config=SCREAMING_SNAKE_CASE__							)
     model.to(SCREAMING_SNAKE_CASE__							)
     model.eval()
     SCREAMING_SNAKE_CASE:Dict   =   model(SCREAMING_SNAKE_CASE__       ,attention_mask=SCREAMING_SNAKE_CASE__       ,token_type_ids=SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:Optional[Any]   =   model(SCREAMING_SNAKE_CASE__       ,token_type_ids=SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:Optional[Any]   =   model(SCREAMING_SNAKE_CASE__							)
     self.parent.assertEqual(result.last_hidden_state.shape       ,(self.batch_size, self.seq_length, self.hidden_size)							)
   def       __UpperCamelCase  (	self     : List[Any]       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : Any       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : str       ,):
     SCREAMING_SNAKE_CASE:Optional[int]   =   True
     SCREAMING_SNAKE_CASE:int   =   YosoModel(SCREAMING_SNAKE_CASE__							)
     model.to(SCREAMING_SNAKE_CASE__							)
     model.eval()
     SCREAMING_SNAKE_CASE:Any   =   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__       ,)
     SCREAMING_SNAKE_CASE:List[Any]   =   model(
         SCREAMING_SNAKE_CASE__       ,attention_mask=SCREAMING_SNAKE_CASE__       ,token_type_ids=SCREAMING_SNAKE_CASE__       ,encoder_hidden_states=SCREAMING_SNAKE_CASE__       ,)
     SCREAMING_SNAKE_CASE: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       __UpperCamelCase  (	self     : int       ,SCREAMING_SNAKE_CASE__     : List[str]       ,SCREAMING_SNAKE_CASE__     : Dict       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]       ,SCREAMING_SNAKE_CASE__     : Any       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]							):
     SCREAMING_SNAKE_CASE:str   =   YosoForMaskedLM(config=SCREAMING_SNAKE_CASE__							)
     model.to(SCREAMING_SNAKE_CASE__							)
     model.eval()
     SCREAMING_SNAKE_CASE:int   =   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       __UpperCamelCase  (	self     : Any       ,SCREAMING_SNAKE_CASE__     : List[Any]       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : Dict       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : Optional[int]							):
     SCREAMING_SNAKE_CASE:Any   =   YosoForQuestionAnswering(config=SCREAMING_SNAKE_CASE__							)
     model.to(SCREAMING_SNAKE_CASE__							)
     model.eval()
     SCREAMING_SNAKE_CASE:List[str]   =   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       __UpperCamelCase  (	self     : str       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : Optional[int]       ,SCREAMING_SNAKE_CASE__     : Optional[int]       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]       ,SCREAMING_SNAKE_CASE__     : List[Any]							):
     SCREAMING_SNAKE_CASE:str   =   self.num_labels
     SCREAMING_SNAKE_CASE:List[str]   =   YosoForSequenceClassification(SCREAMING_SNAKE_CASE__							)
     model.to(SCREAMING_SNAKE_CASE__							)
     model.eval()
     SCREAMING_SNAKE_CASE:Tuple   =   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       __UpperCamelCase  (	self     : int       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : Optional[int]       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : List[str]       ,SCREAMING_SNAKE_CASE__     : List[Any]       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : Any							):
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   self.num_labels
     SCREAMING_SNAKE_CASE:Optional[int]   =   YosoForTokenClassification(config=SCREAMING_SNAKE_CASE__							)
     model.to(SCREAMING_SNAKE_CASE__							)
     model.eval()
     SCREAMING_SNAKE_CASE: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       __UpperCamelCase  (	self     : List[Any]       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : Dict       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]       ,SCREAMING_SNAKE_CASE__     : Optional[int]       ,SCREAMING_SNAKE_CASE__     : List[str]       ,SCREAMING_SNAKE_CASE__     : List[Any]							):
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   self.num_choices
     SCREAMING_SNAKE_CASE:List[Any]   =   YosoForMultipleChoice(config=SCREAMING_SNAKE_CASE__							)
     model.to(SCREAMING_SNAKE_CASE__							)
     model.eval()
     SCREAMING_SNAKE_CASE:List[Any]   =   input_ids.unsqueeze(1							).expand(-1       ,self.num_choices       ,-1							).contiguous()
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   token_type_ids.unsqueeze(1							).expand(-1       ,self.num_choices       ,-1							).contiguous()
     SCREAMING_SNAKE_CASE:Optional[Any]   =   input_mask.unsqueeze(1							).expand(-1       ,self.num_choices       ,-1							).contiguous()
     SCREAMING_SNAKE_CASE:List[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       __UpperCamelCase  (	self     : List[Any]							):
     SCREAMING_SNAKE_CASE:List[Any]   =   self.prepare_config_and_inputs()
     (
         (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      (
         SCREAMING_SNAKE_CASE
     ) ,      
     ):List[str]   =   config_and_inputs
     SCREAMING_SNAKE_CASE:List[str]   =   {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
     return config, inputs_dict





@require_torch
class 							_snake_case	(    _a		,					_a		,					unittest.TestCase  ):
   _A    :       List[Any]      				=   (
       (
           YosoModel,
           YosoForMaskedLM,
           YosoForMultipleChoice,
           YosoForQuestionAnswering,
           YosoForSequenceClassification,
           YosoForTokenClassification,
       )
       if is_torch_available()
       else ()
   )
   _A    :       Any      				=   False
   _A    :       Tuple      				=   False
   _A    :       Dict      				=   False

   _A    :       Any      				=   ()
   _A    :       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       __UpperCamelCase  (	self     : Dict							):
     SCREAMING_SNAKE_CASE:Optional[Any]   =   YosoModelTester(self							)
     SCREAMING_SNAKE_CASE:Any   =   ConfigTester(self       ,config_class=SCREAMING_SNAKE_CASE__       ,hidden_size=37							)
   def       __UpperCamelCase  (	self     : List[Any]							):
     self.config_tester.run_common_tests()
   def       __UpperCamelCase  (	self     : List[str]							):
     SCREAMING_SNAKE_CASE:Any   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : str							):
     SCREAMING_SNAKE_CASE:Tuple   =   self.model_tester.prepare_config_and_inputs()
     for type in ["absolute", "relative_key", "relative_key_query"]:
       SCREAMING_SNAKE_CASE:Union[str, Any]   =   type
       self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : int							):
     SCREAMING_SNAKE_CASE:int   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : Any							):
     SCREAMING_SNAKE_CASE:Optional[int]   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : Any							):
     SCREAMING_SNAKE_CASE:str   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : List[Any]							):
     SCREAMING_SNAKE_CASE:List[Any]   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : Optional[Any]							):
     SCREAMING_SNAKE_CASE:List[Any]   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE__							)
   @slow
   def       __UpperCamelCase  (	self     : Tuple							):
     for model_name in YOSO_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
       SCREAMING_SNAKE_CASE:Tuple   =   YosoModel.from_pretrained(SCREAMING_SNAKE_CASE__							)
       self.assertIsNotNone(SCREAMING_SNAKE_CASE__							)







   def       __UpperCamelCase  (	self     : Any							):
     return





@require_torch
class 							_snake_case	(    unittest.TestCase  ):
   @slow
   def       __UpperCamelCase  (	self     : int							):
     SCREAMING_SNAKE_CASE:Tuple   =   YosoModel.from_pretrained("uw-madison/yoso-4096"							)
     SCREAMING_SNAKE_CASE:Optional[Any]   =   torch.tensor([[0, 1, 2, 3, 4, 5]]							)

     with torch.no_grad():
       SCREAMING_SNAKE_CASE:Optional[Any]   =   model(SCREAMING_SNAKE_CASE__							)[0]

     SCREAMING_SNAKE_CASE:str   =   torch.Size((1, 6, 768)							)
     self.assertEqual(output.shape       ,SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:Tuple   =   torch.tensor(
         [[[-0.0_611, 0.1_242, 0.0_840], [0.0_280, -0.0_048, 0.1_125], [0.0_106, 0.0_226, 0.0_751]]]							)

     self.assertTrue(torch.allclose(output[:, :3, :3]       ,SCREAMING_SNAKE_CASE__       ,atol=1e-4							)							)
   @slow
   def       __UpperCamelCase  (	self     : List[str]							):
     SCREAMING_SNAKE_CASE:Any   =   YosoForMaskedLM.from_pretrained("uw-madison/yoso-4096"							)
     SCREAMING_SNAKE_CASE:List[Any]   =   torch.tensor([[0, 1, 2, 3, 4, 5]]							)

     with torch.no_grad():
       SCREAMING_SNAKE_CASE:List[str]   =   model(SCREAMING_SNAKE_CASE__							)[0]

     SCREAMING_SNAKE_CASE:List[str]   =   50_265

     SCREAMING_SNAKE_CASE:Optional[int]   =   torch.Size((1, 6, vocab_size)							)
     self.assertEqual(output.shape       ,SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:Optional[Any]   =   torch.tensor(
         [[[-2.1_313, -3.7_285, -2.2_407], [-2.7_047, -3.3_314, -2.6_408], [0.0_629, -2.5_166, -0.3_356]]]							)

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







   @slow
   def       __UpperCamelCase  (	self     : List[Any]							):
     SCREAMING_SNAKE_CASE:Dict   =   YosoForMaskedLM.from_pretrained("uw-madison/yoso-4096"							)
     SCREAMING_SNAKE_CASE:Optional[Any]   =   torch.arange(4_096							).unsqueeze(0							)

     with torch.no_grad():
       SCREAMING_SNAKE_CASE:int   =   model(SCREAMING_SNAKE_CASE__							)[0]

     SCREAMING_SNAKE_CASE:Union[str, Any]   =   50_265

     SCREAMING_SNAKE_CASE:Dict   =   torch.Size((1, 4_096, vocab_size)							)
     self.assertEqual(output.shape       ,SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:List[Any]   =   torch.tensor(
         [[[-2.3_914, -4.3_742, -5.0_956], [-4.0_988, -4.2_384, -7.0_406], [-3.1_427, -3.7_192, -6.6_800]]]							)

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









'''simple docstring'''

import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import Mock, patch

import diffusers.utils.hub_utils





class 							_snake_case	(    unittest.TestCase  ):
   @patch("diffusers.utils.hub_utils.get_full_repo_name"							)
   def       __UpperCamelCase  (	self     : List[str]       ,SCREAMING_SNAKE_CASE__     : Mock							):
     SCREAMING_SNAKE_CASE:Optional[Any]   =   "full_repo_name"
     with TemporaryDirectory() as tmpdir:
       # Dummy args values
       SCREAMING_SNAKE_CASE:int   =   Mock()
       SCREAMING_SNAKE_CASE:int   =   tmpdir
       SCREAMING_SNAKE_CASE:Optional[Any]   =   0
       SCREAMING_SNAKE_CASE:Union[str, Any]   =   "hub_token"
       SCREAMING_SNAKE_CASE:str   =   "dataset_name"
       SCREAMING_SNAKE_CASE:Tuple   =   0.01
       SCREAMING_SNAKE_CASE:str   =   100_000
       SCREAMING_SNAKE_CASE:Optional[Any]   =   10_000
       SCREAMING_SNAKE_CASE:List[Any]   =   0.01
       SCREAMING_SNAKE_CASE:Union[str, Any]   =   0.02
       SCREAMING_SNAKE_CASE:Optional[Any]   =   0.03
       SCREAMING_SNAKE_CASE:Tuple   =   0.0_005
       SCREAMING_SNAKE_CASE:List[str]   =   0.000_001
       SCREAMING_SNAKE_CASE:Optional[int]   =   1
       SCREAMING_SNAKE_CASE:Optional[int]   =   10
       SCREAMING_SNAKE_CASE:Any   =   0.001
       SCREAMING_SNAKE_CASE:Optional[int]   =   0.1
       SCREAMING_SNAKE_CASE:Union[str, Any]   =   0.2
       SCREAMING_SNAKE_CASE:Optional[Any]   =   True

       # Model card mush be rendered and saved
       diffusers.utils.hub_utils.create_model_card(SCREAMING_SNAKE_CASE__       ,model_name="model_name"							)
       self.assertTrue((Path(SCREAMING_SNAKE_CASE__							) / "README.md").is_file()							)






