class_docstr: Structured Model Card class. Store model card as well as methods for loading/downloading/saving model cards.
  
  Please read the following paper for details and explanation on the sections: "Model Cards for Model Reporting" by
  Margaret Mitchell, Simone Wu, Andrew Zaldivar, Parker Barnes, Lucy Vasserman, Ben Hutchinson, Elena Spitzer,
  Inioluwa Deborah Raji and Timnit Gebru for the proposal behind model cards. Link: https://arxiv.org/abs/1810.03993
  
  Note: A model card can be loaded and saved to disk.
class_docstr_tok: ["Structured","Model","Card","class",".","Store","model","card","as","well","as","methods","for","loading\/downloading\/saving","model","cards",".","Please","read","the","following","paper","for","details","and","explanation","on","the","sections",":","``","Model","Cards","for","Model","Reporting","''","by","Margaret","Mitchell",",","Simone","Wu",",","Andrew","Zaldivar",",","Parker","Barnes",",","Lucy","Vasserman",",","Ben","Hutchinson",",","Elena","Spitzer",",","Inioluwa","Deborah","Raji","and","Timnit","Gebru","for","the","proposal","behind","model","cards",".","Link",":","https",":","\/\/arxiv.org\/abs\/1810.03993","Note",":","A","model","card","can","be","loaded","and","saved","to","disk","."]
docstr: Instantiate a [`ModelCard`] from a pre-trained model model card.
  
  Parameters:
      pretrained_model_name_or_path: either:
  
          - a string, the *model id* of a pretrained model card hosted inside a model repo on huggingface.co.
            Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
            user or organization name, like `dbmdz/bert-base-german-cased`.
          - a path to a *directory* containing a model card file saved using the [`~ModelCard.save_pretrained`]
            method, e.g.: `./my_model_directory/`.
          - a path or url to a saved model card JSON *file*, e.g.: `./my_model_directory/modelcard.json`.
  
      cache_dir: (*optional*) string:
          Path to a directory in which a downloaded pre-trained model card should be cached if the standard cache
          should not be used.
  
      kwargs: (*optional*) dict: key/value pairs with which to update the ModelCard object after loading.
  
          - The values in kwargs of any keys which are model card attributes will be used to override the loaded
            values.
          - Behavior concerning key/value pairs whose keys are *not* model card attributes is controlled by the
            *return_unused_kwargs* keyword parameter.
  
      proxies: (*optional*) dict, default None:
          A dictionary of proxy servers to use by protocol or endpoint, e.g.: {'http': 'foo.bar:3128',
          'http://hostname': 'foo.bar:4012'}. The proxies are used on each request.
  
      return_unused_kwargs: (*optional*) bool:
  
          - If False, then this function returns just the final model card object.
          - If True, then this functions returns a tuple *(model card, unused_kwargs)* where *unused_kwargs* is a
            dictionary consisting of the key/value pairs whose keys are not model card attributes: ie the part of
            kwargs which has not been used to update *ModelCard* and is otherwise ignored.
  
  Examples:
  
  ```python
  # Download model card from huggingface.co and cache.
  modelcard = ModelCard.from_pretrained("bert-base-uncased")
  # Model card was saved using *save_pretrained('./test/saved_model/')*
  modelcard = ModelCard.from_pretrained("./test/saved_model/")
  modelcard = ModelCard.from_pretrained("./test/saved_model/modelcard.json")
  modelcard = ModelCard.from_pretrained("bert-base-uncased", output_attentions=True, foo=False)
  ```
docstr_tok: ["Instantiate","a","[","`","ModelCard","`","]","from","a","pre-trained","model","model","card",".","Parameters",":","pretrained_model_name_or_path",":","either",":","-","a","string",",","the","*","model","id","*","of","a","pretrained","model","card","hosted","inside","a","model","repo","on","huggingface.co",".","Valid","model","ids","can","be","located","at","the","root-level",",","like","`","bert-base-uncased","`",",","or","namespaced","under","a","user","or","organization","name",",","like","`","dbmdz\/bert-base-german-cased","`",".","-","a","path","to","a","*","directory","*","containing","a","model","card","file","saved","using","the","[","`","~ModelCard.save_pretrained","`","]","method",",","e.g",".",":","`",".\/my_model_directory\/","`",".","-","a","path","or","url","to","a","saved","model","card","JSON","*","file","*",",","e.g",".",":","`",".\/my_model_directory\/modelcard.json","`",".","cache_dir",":","(","*","optional","*",")","string",":","Path","to","a","directory","in","which","a","downloaded","pre-trained","model","card","should","be","cached","if","the","standard","cache","should","not","be","used",".","kwargs",":","(","*","optional","*",")","dict",":","key\/value","pairs","with","which","to","update","the","ModelCard","object","after","loading",".","-","The","values","in","kwargs","of","any","keys","which","are","model","card","attributes","will","be","used","to","override","the","loaded","values",".","-","Behavior","concerning","key\/value","pairs","whose","keys","are","*","not","*","model","card","attributes","is","controlled","by","the","*","return_unused_kwargs","*","keyword","parameter",".","proxies",":","(","*","optional","*",")","dict",",","default","None",":","A","dictionary","of","proxy","servers","to","use","by","protocol","or","endpoint",",","e.g",".",":","{","'http","'",":","'foo.bar:3128","'",",","'http",":","\/\/hostname","'",":","'foo.bar:4012","'","}",".","The","proxies","are","used","on","each","request",".","return_unused_kwargs",":","(","*","optional","*",")","bool",":","-","If","False",",","then","this","function","returns","just","the","final","model","card","object",".","-","If","True",",","then","this","functions","returns","a","tuple","*","(","model","card",",","unused_kwargs",")","*","where","*","unused_kwargs","*","is","a","dictionary","consisting","of","the","key\/value","pairs","whose","keys","are","not","model","card","attributes",":","ie","the","part","of","kwargs","which","has","not","been","used","to","update","*","ModelCard","*","and","is","otherwise","ignored",".","Examples",":","``","`","python","#","Download","model","card","from","huggingface.co","and","cache",".","modelcard","=","ModelCard.from_pretrained","(","``","bert-base-uncased","''",")","#","Model","card","was","saved","using","*","save_pretrained","(","'.\/test\/saved_model\/","'",")","*","modelcard","=","ModelCard.from_pretrained","(","``",".\/test\/saved_model\/","''",")","modelcard","=","ModelCard.from_pretrained","(","``",".\/test\/saved_model\/modelcard.json","''",")","modelcard","=","ModelCard.from_pretrained","(","``","bert-base-uncased","''",",","output_attentions=True",",","foo=False",")","``","`"]
code: def from_pretrained(cls, pretrained_model_name_or_path, **kwargs):
      r"""
      Instantiate a [`ModelCard`] from a pre-trained model model card.
  
      Parameters:
          pretrained_model_name_or_path: either:
  
              - a string, the *model id* of a pretrained model card hosted inside a model repo on huggingface.co.
                Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
                user or organization name, like `dbmdz/bert-base-german-cased`.
              - a path to a *directory* containing a model card file saved using the [`~ModelCard.save_pretrained`]
                method, e.g.: `./my_model_directory/`.
              - a path or url to a saved model card JSON *file*, e.g.: `./my_model_directory/modelcard.json`.
  
          cache_dir: (*optional*) string:
              Path to a directory in which a downloaded pre-trained model card should be cached if the standard cache
              should not be used.
  
          kwargs: (*optional*) dict: key/value pairs with which to update the ModelCard object after loading.
  
              - The values in kwargs of any keys which are model card attributes will be used to override the loaded
                values.
              - Behavior concerning key/value pairs whose keys are *not* model card attributes is controlled by the
                *return_unused_kwargs* keyword parameter.
  
          proxies: (*optional*) dict, default None:
              A dictionary of proxy servers to use by protocol or endpoint, e.g.: {'http': 'foo.bar:3128',
              'http://hostname': 'foo.bar:4012'}. The proxies are used on each request.
  
          return_unused_kwargs: (*optional*) bool:
  
              - If False, then this function returns just the final model card object.
              - If True, then this functions returns a tuple *(model card, unused_kwargs)* where *unused_kwargs* is a
                dictionary consisting of the key/value pairs whose keys are not model card attributes: ie the part of
                kwargs which has not been used to update *ModelCard* and is otherwise ignored.
  
      Examples:
  
      ```python
      # Download model card from huggingface.co and cache.
      modelcard = ModelCard.from_pretrained("bert-base-uncased")
      # Model card was saved using *save_pretrained('./test/saved_model/')*
      modelcard = ModelCard.from_pretrained("./test/saved_model/")
      modelcard = ModelCard.from_pretrained("./test/saved_model/modelcard.json")
      modelcard = ModelCard.from_pretrained("bert-base-uncased", output_attentions=True, foo=False)
      ```"""
      cache_dir = kwargs.pop("cache_dir", None)
      proxies = kwargs.pop("proxies", None)
      return_unused_kwargs = kwargs.pop("return_unused_kwargs", False)
      from_pipeline = kwargs.pop("_from_pipeline", None)
  
      user_agent = {"file_type": "model_card"}
      if from_pipeline is not None:
          user_agent["using_pipeline"] = from_pipeline
  
      is_local = os.path.isdir(pretrained_model_name_or_path)
      if os.path.isfile(pretrained_model_name_or_path):
          resolved_model_card_file = pretrained_model_name_or_path
          is_local = True
      else:
          try:
              # Load from URL or cache if already cached
              resolved_model_card_file = cached_file(
                  pretrained_model_name_or_path,
                  filename=MODEL_CARD_NAME,
                  cache_dir=cache_dir,
                  proxies=proxies,
                  user_agent=user_agent,
              )
              if is_local:
                  logger.info(
                      f"loading model card file {resolved_model_card_file}"
                  )
              else:
                  logger.info(
                      f"loading model card file {MODEL_CARD_NAME} from cache at {resolved_model_card_file}"
                  )
              # Load model card
              modelcard = cls.from_json_file(resolved_model_card_file)
  
          except (EnvironmentError, json.JSONDecodeError):
              # We fall back on creating an empty model card
              modelcard = cls()
  
      # Update model card with kwargs if needed
      to_remove = []
      for key, value in kwargs.items():
          if hasattr(modelcard, key):
              setattr(modelcard, key, value)
              to_remove.append(key)
      for key in to_remove:
          kwargs.pop(key, None)
  
      logger.info(f"Model card: {modelcard}")
      if return_unused_kwargs:
          return modelcard, kwargs
      else:
          return modelcard
  
imports: import copy
  import json
  import os
  import warnings
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Union
  import requests
  import yaml
  from huggingface_hub import model_info
  from huggingface_hub.utils import HFValidationError
  from .None import __version__
  from .models.auto.modeling_auto import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES, MODEL_FOR_CAUSAL_LM_MAPPING_NAMES, MODEL_FOR_CTC_MAPPING_NAMES, MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES, MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES, MODEL_FOR_MASKED_LM_MAPPING_NAMES, MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES, MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES, MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES, MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES, MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES, MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING_NAMES, MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES
  from .training_args import ParallelMode
  from .utils import MODEL_CARD_NAME, cached_file, is_datasets_available, is_offline_mode, is_tf_available, is_tokenizers_available, is_torch_available, logging
label_desc: Use image node_id 3 for calling the ModelCard obj's underlying member method code with example usage: obj.from_pretrained(cls, pretrained_model_name_or_path) and returns: modelcard,  kwargs, modelcard