docstr: Initialize a RepoCard from a Hugging Face Hub repo's README.md or a local filepath.
  
  Args:
      repo_id_or_path (`Union[str, Path]`):
          The repo ID associated with a Hugging Face Hub repo or a local filepath.
      repo_type (`str`, *optional*):
          The type of Hugging Face repo to push to. Defaults to None, which will use use "model". Other options
          are "dataset" and "space". Not used when loading from a local filepath. If this is called from a child
          class, the default value will be the child class's `repo_type`.
      token (`str`, *optional*):
          Authentication token, obtained with `huggingface_hub.HfApi.login` method. Will default to the stored token.
      ignore_metadata_errors (`str`):
          If True, errors while parsing the metadata section will be ignored. Some information might be lost during
          the process. Use it at your own risk.
  
  Returns:
      [`huggingface_hub.repocard.RepoCard`]: The RepoCard (or subclass) initialized from the repo's
          README.md file or filepath.
  
  Example:
      ```python
      >>> from huggingface_hub.repocard import RepoCard
      >>> card = RepoCard.load("nateraw/food")
      >>> assert card.data.tags == ["generated_from_trainer", "image-classification", "pytorch"]
  
      ```
docstr_tok: ["Initialize","a","RepoCard","from","a","Hugging","Face","Hub","repo","'s","README.md","or","a","local","filepath",".","Args",":","repo_id_or_path","(","`","Union","[","str",",","Path","]","`",")",":","The","repo","ID","associated","with","a","Hugging","Face","Hub","repo","or","a","local","filepath",".","repo_type","(","`","str","`",",","*","optional","*",")",":","The","type","of","Hugging","Face","repo","to","push","to",".","Defaults","to","None",",","which","will","use","use","``","model","''",".","Other","options","are","``","dataset","''","and","``","space","''",".","Not","used","when","loading","from","a","local","filepath",".","If","this","is","called","from","a","child","class",",","the","default","value","will","be","the","child","class","'s","`","repo_type","`",".","token","(","`","str","`",",","*","optional","*",")",":","Authentication","token",",","obtained","with","`","huggingface_hub.HfApi.login","`","method",".","Will","default","to","the","stored","token",".","ignore_metadata_errors","(","`","str","`",")",":","If","True",",","errors","while","parsing","the","metadata","section","will","be","ignored",".","Some","information","might","be","lost","during","the","process",".","Use","it","at","your","own","risk",".","Returns",":","[","`","huggingface_hub.repocard.RepoCard","`","]",":","The","RepoCard","(","or","subclass",")","initialized","from","the","repo's","README.md","file","or","filepath",".","Example",":","``","`","python",">",">",">","from","huggingface_hub.repocard","import","RepoCard",">",">",">","card","=","RepoCard.load","(","``","nateraw\/food","''",")",">",">",">","assert","card.data.tags","==","[","``","generated_from_trainer","''",",","``","image-classification","''",",","``","pytorch","''","]","``","`"]
code: def load(
      cls,
      repo_id_or_path: Union[str, Path],
      repo_type: Optional[str] = None,
      token: Optional[str] = None,
      ignore_metadata_errors: bool = False,
  ):
      """Initialize a RepoCard from a Hugging Face Hub repo's README.md or a local filepath.
  
      Args:
          repo_id_or_path (`Union[str, Path]`):
              The repo ID associated with a Hugging Face Hub repo or a local filepath.
          repo_type (`str`, *optional*):
              The type of Hugging Face repo to push to. Defaults to None, which will use use "model". Other options
              are "dataset" and "space". Not used when loading from a local filepath. If this is called from a child
              class, the default value will be the child class's `repo_type`.
          token (`str`, *optional*):
              Authentication token, obtained with `huggingface_hub.HfApi.login` method. Will default to the stored token.
          ignore_metadata_errors (`str`):
              If True, errors while parsing the metadata section will be ignored. Some information might be lost during
              the process. Use it at your own risk.
  
      Returns:
          [`huggingface_hub.repocard.RepoCard`]: The RepoCard (or subclass) initialized from the repo's
              README.md file or filepath.
  
      Example:
          ```python
          >>> from huggingface_hub.repocard import RepoCard
          >>> card = RepoCard.load("nateraw/food")
          >>> assert card.data.tags == ["generated_from_trainer", "image-classification", "pytorch"]
  
          ```
      """
  
      if Path(repo_id_or_path).exists():
          card_path = Path(repo_id_or_path)
      elif isinstance(repo_id_or_path, str):
          card_path = Path(
              hf_hub_download(
                  repo_id_or_path,
                  REPOCARD_NAME,
                  repo_type=repo_type or cls.repo_type,
                  token=token,
              )
          )
      else:
          raise ValueError(
              f"Cannot load RepoCard: path not found on disk ({repo_id_or_path})."
          )
  
      # Preserve newlines in the existing file.
      with card_path.open(mode="r", newline="", encoding="utf-8") as f:
          return cls(
              f.read(), ignore_metadata_errors=ignore_metadata_errors
          )
  
imports: import os
  import re
  from pathlib import Path
  from typing import Any, Dict, Literal, Optional, Type, Union
  import requests
  import yaml
  from huggingface_hub.file_download import hf_hub_download
  from huggingface_hub.hf_api import upload_file
  from huggingface_hub.repocard_data import CardData, DatasetCardData, EvalResult, ModelCardData, SpaceCardData, eval_results_to_model_index, model_index_to_eval_results
  from huggingface_hub.utils import get_session, is_jinja_available, yaml_dump
  from .constants import REPOCARD_NAME
  from .utils import EntryNotFoundError, SoftTemporaryDirectory, logging, validate_hf_hub_args
label_desc: Use image node_id 6 for calling the RepoCard obj's underlying member method code with example usage: obj.load(cls, repo_id_or_path, repo_type, token, ignore_metadata_errors) and returns: cls