docstr: Save a RepoCard to a file.
  
  Args:
      filepath (`Union[Path, str]`): Filepath to the markdown file to save.
  
  Example:
      ```python
      >>> from huggingface_hub.repocard import RepoCard
      >>> card = RepoCard("---\nlanguage: en\n---\n# This is a test repo card")
      >>> card.save("/tmp/test.md")
  
      ```
docstr_tok: ["Save","a","RepoCard","to","a","file",".","Args",":","filepath","(","`","Union","[","Path",",","str","]","`",")",":","Filepath","to","the","markdown","file","to","save",".","Example",":","``","`","python",">",">",">","from","huggingface_hub.repocard","import","RepoCard",">",">",">","card","=","RepoCard","(","``","--","-\\nlanguage",":","en\\n","--","-\\n","#","This","is","a","test","repo","card","''",")",">",">",">","card.save","(","``","\/tmp\/test.md","''",")","``","`"]
code: def save(self, filepath: Union[Path, str]):
      r"""Save a RepoCard to a file.
  
      Args:
          filepath (`Union[Path, str]`): Filepath to the markdown file to save.
  
      Example:
          ```python
          >>> from huggingface_hub.repocard import RepoCard
          >>> card = RepoCard("---\nlanguage: en\n---\n# This is a test repo card")
          >>> card.save("/tmp/test.md")
  
          ```
      """
      filepath = Path(filepath)
      filepath.parent.mkdir(parents=True, exist_ok=True)
      # Preserve newlines as in the existing file.
      with open(filepath, mode="w", newline="", encoding="utf-8") as f:
          f.write(str(self))
  
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 5 for calling the RepoCard obj's underlying member method code with example usage: obj.save(filepath) without return types