
import json
import os
import tempfile
import unittest

from transformers.modelcard import ModelCard
class     SCREAMING_SNAKE_CASE__     (						unittest.TestCase		):





       '''simple docstring'''




       def UpperCAmelCase_						(						self       :						Dict							)			->    str:
             snake_case__					=   {
                 '''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 UpperCAmelCase_						(						self       :						Dict							)			->    List[Any]:
             snake_case__					=   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 UpperCAmelCase_						(						self       :						Dict							)			->    Union[str, Any]:
             snake_case__					=   ModelCard.from_dict(self.inputs_dict							)
             snake_case__					=   json.loads(modelcard.to_json_string()							)
             for key, value in self.inputs_dict.items():
                   self.assertEqual(obj[key]    ,		_snake_case							)

       def UpperCAmelCase_						(						self       :						Tuple							)			->    Any:
             snake_case__					=   ModelCard.from_dict(self.inputs_dict							)

             with tempfile.TemporaryDirectory() as tmpdirname:
                   snake_case__					=   os.path.join(_snake_case    ,		"""modelcard.json"""							)
                   model_card_first.to_json_file(_snake_case							)
                   snake_case__					=   ModelCard.from_json_file(_snake_case							)

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

       def UpperCAmelCase_						(						self       :						List[Any]							)			->    List[Any]:
             snake_case__					=   ModelCard.from_dict(self.inputs_dict							)

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

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









from doctest import testmod
from math import sqrt





def 			_lowercase    (      __UpperCamelCase     :		int ):
      snake_case__					=   []
      if num < 1:
            return facs
      facs.append(1 )
      if num == 1:
            return facs
      facs.append(__UpperCamelCase )
      for i in range(2   ,       int(sqrt(__UpperCamelCase ) ) + 1 ):
            if num % i == 0:  # If i is a factor of num
                  facs.append(__UpperCamelCase )
                  snake_case__					=   num // i  # num//i is the other factor of num
                  if d != i:  # If d and i are distinct
                        facs.append(__UpperCamelCase )  # we have found another factor
      facs.sort()
      return facs


if __name__ == "__main__":
       testmod(name='''factors_of_a_number''', verbose=True)






