
import json
import os
import tempfile
import unittest

from transformers.modelcard import ModelCard


class   __lowerCAmelCase		(		unittest.TestCase ):



      """simple docstring"""







      def 						snake_case_     ( self						:    Tuple			):
          __lowercase						:     Dict		      =    {
              '''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''': 76},
          }




      def 						snake_case_     ( self						:    int			):
          __lowercase						:     Union[str, Any]		      =    ModelCard.from_dict(self.inputs_dict			)
          self.assertTrue(hasattr(_snake_case			,    '''model_details'''			)			)
          self.assertTrue(hasattr(_snake_case			,    '''intended_use'''			)			)
          self.assertTrue(hasattr(_snake_case			,    '''factors'''			)			)
          self.assertTrue(hasattr(_snake_case			,    '''metrics'''			)			)
          self.assertTrue(hasattr(_snake_case			,    '''evaluation_data'''			)			)
          self.assertTrue(hasattr(_snake_case			,    '''training_data'''			)			)
          self.assertTrue(hasattr(_snake_case			,    '''quantitative_analyses'''			)			)
          self.assertTrue(hasattr(_snake_case			,    '''ethical_considerations'''			)			)
          self.assertTrue(hasattr(_snake_case			,    '''caveats_and_recommendations'''			)			)




      def 						snake_case_     ( self						:    Optional[Any]			):
          __lowercase						:     List[str]		      =    ModelCard.from_dict(self.inputs_dict			)
          __lowercase						:     Dict		      =    json.loads(modelcard.to_json_string()			)
          for key, value in self.inputs_dict.items():
              self.assertEqual(obj[key]			,    _snake_case			)




      def 						snake_case_     ( self						:    Union[str, Any]			):
          __lowercase						:     Union[str, Any]		      =    ModelCard.from_dict(self.inputs_dict			)

          with tempfile.TemporaryDirectory() as tmpdirname:
              __lowercase						:     Tuple		      =    os.path.join(_snake_case			,    '''modelcard.json'''			)
              model_card_first.to_json_file(_snake_case			)
              __lowercase						:     List[str]		      =    ModelCard.from_json_file(_snake_case			)

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




      def 						snake_case_     ( self						:    Optional[int]			):
          __lowercase						:     List[Any]		      =    ModelCard.from_dict(self.inputs_dict			)

          with tempfile.TemporaryDirectory() as tmpdirname:
              model_card_first.save_pretrained(_snake_case			)
              __lowercase						:     Any		      =    ModelCard.from_pretrained(_snake_case			)

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




from ..utils import DummyObject, requires_backends


class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[Any]       				=      ['''tokenizers''']




      def __init__( self						:    Any			,    *_snake_case						:    Optional[int]			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Tuple			,    *_snake_case						:    List[Any]			,    **_snake_case						:    Tuple			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[int]       				=      ['''tokenizers''']




      def __init__( self						:    List[Any]			,    *_snake_case						:    List[Any]			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[str]       				=      ['''tokenizers''']




      def __init__( self						:    Optional[int]			,    *_snake_case						:    List[Any]			,    **_snake_case						:    int			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Optional[int]			,    *_snake_case						:    List[str]			,    **_snake_case						:    int			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[int]       				=      ['''tokenizers''']




      def __init__( self						:    Optional[int]			,    *_snake_case						:    List[str]			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Any       				=      ['''tokenizers''']




      def __init__( self						:    List[str]			,    *_snake_case						:    Union[str, Any]			,    **_snake_case						:    Optional[int]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Any       				=      ['''tokenizers''']




      def __init__( self						:    Optional[Any]			,    *_snake_case						:    Tuple			,    **_snake_case						:    List[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     str       				=      ['''tokenizers''']




      def __init__( self						:    Tuple			,    *_snake_case						:    List[str]			,    **_snake_case						:    Dict			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[Any]       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    Optional[int]			,    **_snake_case						:    int			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[Any]       				=      ['''tokenizers''']




      def __init__( self						:    Any			,    *_snake_case						:    Optional[int]			,    **_snake_case						:    Optional[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     str       				=      ['''tokenizers''']




      def __init__( self						:    Optional[Any]			,    *_snake_case						:    Tuple			,    **_snake_case						:    str			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     int       				=      ['''tokenizers''']




      def __init__( self						:    Optional[Any]			,    *_snake_case						:    List[Any]			,    **_snake_case						:    str			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Any       				=      ['''tokenizers''']




      def __init__( self						:    int			,    *_snake_case						:    Dict			,    **_snake_case						:    Optional[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[Any]       				=      ['''tokenizers''']




      def __init__( self						:    int			,    *_snake_case						:    Optional[Any]			,    **_snake_case						:    List[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[int]       				=      ['''tokenizers''']




      def __init__( self						:    Optional[Any]			,    *_snake_case						:    Dict			,    **_snake_case						:    Union[str, Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[Any]       				=      ['''tokenizers''']




      def __init__( self						:    List[str]			,    *_snake_case						:    Union[str, Any]			,    **_snake_case						:    List[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[Any]       				=      ['''tokenizers''']




      def __init__( self						:    List[str]			,    *_snake_case						:    int			,    **_snake_case						:    Optional[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    List[Any]			,    *_snake_case						:    str			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[int]       				=      ['''tokenizers''']




      def __init__( self						:    Any			,    *_snake_case						:    List[Any]			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     int       				=      ['''tokenizers''']




      def __init__( self						:    List[str]			,    *_snake_case						:    Dict			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[Any]       				=      ['''tokenizers''']




      def __init__( self						:    Optional[Any]			,    *_snake_case						:    Union[str, Any]			,    **_snake_case						:    Dict			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[str]       				=      ['''tokenizers''']




      def __init__( self						:    List[Any]			,    *_snake_case						:    List[str]			,    **_snake_case						:    Optional[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Any       				=      ['''tokenizers''']




      def __init__( self						:    Union[str, Any]			,    *_snake_case						:    int			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[str]       				=      ['''tokenizers''']




      def __init__( self						:    Union[str, Any]			,    *_snake_case						:    str			,    **_snake_case						:    Union[str, Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Tuple       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    Any			,    **_snake_case						:    Tuple			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    int			,    *_snake_case						:    List[str]			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[int]       				=      ['''tokenizers''']




      def __init__( self						:    List[str]			,    *_snake_case						:    Optional[Any]			,    **_snake_case						:    Tuple			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[str]       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    List[str]			,    **_snake_case						:    Union[str, Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Union[str, Any]       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    Union[str, Any]			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Any			,    *_snake_case						:    Optional[int]			,    **_snake_case						:    str			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[Any]       				=      ['''tokenizers''']




      def __init__( self						:    str			,    *_snake_case						:    List[str]			,    **_snake_case						:    Union[str, Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Union[str, Any]       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    Dict			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     str       				=      ['''tokenizers''']




      def __init__( self						:    Tuple			,    *_snake_case						:    Dict			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Any       				=      ['''tokenizers''']




      def __init__( self						:    Optional[int]			,    *_snake_case						:    List[Any]			,    **_snake_case						:    Tuple			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Union[str, Any]       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    str			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Union[str, Any]       				=      ['''tokenizers''']




      def __init__( self						:    Optional[Any]			,    *_snake_case						:    Dict			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     int       				=      ['''tokenizers''']




      def __init__( self						:    Any			,    *_snake_case						:    List[str]			,    **_snake_case						:    str			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Union[str, Any]       				=      ['''tokenizers''']




      def __init__( self						:    Tuple			,    *_snake_case						:    Dict			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Union[str, Any]			,    *_snake_case						:    Any			,    **_snake_case						:    Optional[int]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[str]       				=      ['''tokenizers''']




      def __init__( self						:    Optional[int]			,    *_snake_case						:    List[Any]			,    **_snake_case						:    Any			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[str]       				=      ['''tokenizers''']




      def __init__( self						:    Tuple			,    *_snake_case						:    str			,    **_snake_case						:    int			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     str       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    Tuple			,    **_snake_case						:    Dict			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[Any]       				=      ['''tokenizers''']




      def __init__( self						:    List[str]			,    *_snake_case						:    str			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Union[str, Any]       				=      ['''tokenizers''']




      def __init__( self						:    Optional[int]			,    *_snake_case						:    List[Any]			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    str			,    *_snake_case						:    Tuple			,    **_snake_case						:    Optional[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     int       				=      ['''tokenizers''']




      def __init__( self						:    Tuple			,    *_snake_case						:    Any			,    **_snake_case						:    List[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     int       				=      ['''tokenizers''']




      def __init__( self						:    Any			,    *_snake_case						:    Optional[Any]			,    **_snake_case						:    List[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Union[str, Any]       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    str			,    **_snake_case						:    Optional[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Any			,    *_snake_case						:    str			,    **_snake_case						:    Tuple			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    List[Any]			,    **_snake_case						:    Optional[int]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[int]       				=      ['''tokenizers''']




      def __init__( self						:    Optional[Any]			,    *_snake_case						:    Dict			,    **_snake_case						:    Optional[int]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Tuple			,    *_snake_case						:    Dict			,    **_snake_case						:    int			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     str       				=      ['''tokenizers''']




      def __init__( self						:    Optional[int]			,    *_snake_case						:    List[str]			,    **_snake_case						:    str			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     List[str]       				=      ['''tokenizers''']




      def __init__( self						:    int			,    *_snake_case						:    str			,    **_snake_case						:    Union[str, Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Tuple			,    *_snake_case						:    Optional[Any]			,    **_snake_case						:    Optional[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Dict       				=      ['''tokenizers''']




      def __init__( self						:    Dict			,    *_snake_case						:    Tuple			,    **_snake_case						:    Optional[Any]			):
          requires_backends(self			,    ['''tokenizers''']			)






class   __lowerCAmelCase		(		metaclass=lowerCAmelCase_ ):



      """simple docstring"""







      A__		:     Optional[Any]       				=      ['''tokenizers''']




      def __init__( self						:    List[str]			,    *_snake_case						:    Optional[int]			,    **_snake_case						:    List[str]			):
          requires_backends(self			,    ['''tokenizers''']			)


