


"""simple docstring"""





import json
import os
import tempfile
import unittest

from transformers.modelcard import ModelCard

class  lowercase_  ( unittest.TestCase						):







      def 				_lowerCAmelCase       (      self :							Tuple    ):
        lowerCAmelCase__    :    str								=					{
            '''model_details''': {
                '''Organization''': '''testing''',
                '''Model date''': '''today''',
                '''Model version''': '''v2.1, Developed by Test Corp in 2019.''',
                '''Architecture''': '''Convolutional Neural Network.''',
            },
            '''metrics''': '''BLEU and ROUGE-1''',
            '''evaluation_data''': {
                '''Datasets''': {'''BLEU''': '''My-great-dataset-v1''', '''ROUGE-1''': '''My-short-dataset-v2.1'''},
                '''Preprocessing''': '''See details on https://arxiv.org/pdf/1810.03993.pdf''',
            },
            '''training_data''': {
                '''Dataset''': '''English Wikipedia dump dated 2018-12-01''',
                '''Preprocessing''': (
                    '''Using SentencePiece vocabulary of size 52k tokens. See details on'''
                    ''' https://arxiv.org/pdf/1810.03993.pdf'''
                ),
            },
            '''quantitative_analyses''': {'''BLEU''': 55.1, '''ROUGE-1''': 7_6},
        }







      def 				_lowerCAmelCase       (      self :							List[Any]    ):
        lowerCAmelCase__    :    Any								=					ModelCard.from_dict(self.inputs_dict    )
        self.assertTrue(hasattr(_lowercase		,  "model_details"    )    )
        self.assertTrue(hasattr(_lowercase		,  "intended_use"    )    )
        self.assertTrue(hasattr(_lowercase		,  "factors"    )    )
        self.assertTrue(hasattr(_lowercase		,  "metrics"    )    )
        self.assertTrue(hasattr(_lowercase		,  "evaluation_data"    )    )
        self.assertTrue(hasattr(_lowercase		,  "training_data"    )    )
        self.assertTrue(hasattr(_lowercase		,  "quantitative_analyses"    )    )
        self.assertTrue(hasattr(_lowercase		,  "ethical_considerations"    )    )
        self.assertTrue(hasattr(_lowercase		,  "caveats_and_recommendations"    )    )







      def 				_lowerCAmelCase       (      self :							Tuple    ):
        lowerCAmelCase__    :    Dict								=					ModelCard.from_dict(self.inputs_dict    )
        lowerCAmelCase__    :    Tuple								=					json.loads(modelcard.to_json_string()    )
        for key, value in self.inputs_dict.items():
          self.assertEqual(obj[key]		,  _lowercase    )







      def 				_lowerCAmelCase       (      self :							Tuple    ):
        lowerCAmelCase__    :    Optional[Any]								=					ModelCard.from_dict(self.inputs_dict    )

        with tempfile.TemporaryDirectory() as tmpdirname:
          lowerCAmelCase__    :    Optional[int]								=					os.path.join(_lowercase		,  "modelcard.json"    )
          model_card_first.to_json_file(_lowercase    )
          lowerCAmelCase__    :    Dict								=					ModelCard.from_json_file(_lowercase    )

        self.assertEqual(model_card_second.to_dict()		,  model_card_first.to_dict()    )







      def 				_lowerCAmelCase       (      self :							str    ):
        lowerCAmelCase__    :    Optional[Any]								=					ModelCard.from_dict(self.inputs_dict    )

        with tempfile.TemporaryDirectory() as tmpdirname:
          model_card_first.save_pretrained(_lowercase    )
          lowerCAmelCase__    :    Union[str, Any]								=					ModelCard.from_pretrained(_lowercase    )

        self.assertEqual(model_card_second.to_dict()		,  model_card_first.to_dict()    )




"""simple docstring"""





from ...configuration_utils import PretrainedConfig
from ...utils import logging


__UpperCAmelCase    				=      logging.get_logger(__name__)

__UpperCAmelCase    				=      {
    "MCG-NJU/videomae-base": "https://huggingface.co/MCG-NJU/videomae-base/resolve/main/config.json",
}

class  lowercase_  ( a_						):
      __magic_name__     :							Union[str, Any]          =				"""videomae"""







      def __init__(      self :							Dict		,  _lowercase :							int=2_2_4		,  _lowercase :							Optional[Any]=1_6		,  _lowercase :							List[Any]=3		,  _lowercase :							int=1_6		,  _lowercase :							Optional[Any]=2		,  _lowercase :							Union[str, Any]=7_6_8		,  _lowercase :							int=1_2		,  _lowercase :							Dict=1_2		,  _lowercase :							Optional[Any]=3_0_7_2		,  _lowercase :							List[str]="gelu"		,  _lowercase :							int=0.0		,  _lowercase :							int=0.0		,  _lowercase :							Optional[int]=0.02		,  _lowercase :							List[str]=1e-1_2		,  _lowercase :							Union[str, Any]=True		,  _lowercase :							Union[str, Any]=True		,  _lowercase :							Any=6		,  _lowercase :							Any=3_8_4		,  _lowercase :							int=4		,  _lowercase :							Optional[int]=1_5_3_6		,  _lowercase :							Tuple=True		,  **_lowercase :							List[str]		,  ):
        super().__init__(**_lowercase    )

        lowerCAmelCase__    :    List[Any]								=					image_size
        lowerCAmelCase__    :    Tuple								=					patch_size
        lowerCAmelCase__    :    Union[str, Any]								=					num_channels
        lowerCAmelCase__    :    Optional[Any]								=					num_frames
        lowerCAmelCase__    :    Union[str, Any]								=					tubelet_size

        lowerCAmelCase__    :    Union[str, Any]								=					hidden_size
        lowerCAmelCase__    :    Dict								=					num_hidden_layers
        lowerCAmelCase__    :    Any								=					num_attention_heads
        lowerCAmelCase__    :    List[Any]								=					intermediate_size
        lowerCAmelCase__    :    Optional[Any]								=					hidden_act
        lowerCAmelCase__    :    int								=					hidden_dropout_prob
        lowerCAmelCase__    :    Optional[Any]								=					attention_probs_dropout_prob
        lowerCAmelCase__    :    Any								=					initializer_range
        lowerCAmelCase__    :    Any								=					layer_norm_eps
        lowerCAmelCase__    :    Union[str, Any]								=					qkv_bias
        lowerCAmelCase__    :    int								=					use_mean_pooling

        lowerCAmelCase__    :    List[Any]								=					decoder_num_attention_heads
        lowerCAmelCase__    :    List[str]								=					decoder_hidden_size
        lowerCAmelCase__    :    int								=					decoder_num_hidden_layers
        lowerCAmelCase__    :    Optional[int]								=					decoder_intermediate_size
        lowerCAmelCase__    :    Optional[Any]								=					norm_pix_loss
