docstr: Initialize a RepoCard from a template. By default, it uses the default template.
  
  Templates are Jinja2 templates that can be customized by passing keyword arguments.
  
  Args:
      card_data (`huggingface_hub.CardData`):
          A huggingface_hub.CardData instance containing the metadata you want to include in the YAML
          header of the repo card on the Hugging Face Hub.
      template_path (`str`, *optional*):
          A path to a markdown file with optional Jinja template variables that can be filled
          in with `template_kwargs`. Defaults to the default template.
  
  Returns:
      [`huggingface_hub.repocard.RepoCard`]: A RepoCard instance with the specified card data and content from the
      template.
docstr_tok: ["Initialize","a","RepoCard","from","a","template",".","By","default",",","it","uses","the","default","template",".","Templates","are","Jinja2","templates","that","can","be","customized","by","passing","keyword","arguments",".","Args",":","card_data","(","`","huggingface_hub.CardData","`",")",":","A","huggingface_hub.CardData","instance","containing","the","metadata","you","want","to","include","in","the","YAML","header","of","the","repo","card","on","the","Hugging","Face","Hub",".","template_path","(","`","str","`",",","*","optional","*",")",":","A","path","to","a","markdown","file","with","optional","Jinja","template","variables","that","can","be","filled","in","with","`","template_kwargs","`",".","Defaults","to","the","default","template",".","Returns",":","[","`","huggingface_hub.repocard.RepoCard","`","]",":","A","RepoCard","instance","with","the","specified","card","data","and","content","from","the","template","."]
code: def from_template(
      cls,
      card_data: CardData,
      template_path: Optional[str] = None,
      **template_kwargs,
  ):
      """Initialize a RepoCard from a template. By default, it uses the default template.
  
      Templates are Jinja2 templates that can be customized by passing keyword arguments.
  
      Args:
          card_data (`huggingface_hub.CardData`):
              A huggingface_hub.CardData instance containing the metadata you want to include in the YAML
              header of the repo card on the Hugging Face Hub.
          template_path (`str`, *optional*):
              A path to a markdown file with optional Jinja template variables that can be filled
              in with `template_kwargs`. Defaults to the default template.
  
      Returns:
          [`huggingface_hub.repocard.RepoCard`]: A RepoCard instance with the specified card data and content from the
          template.
      """
      if is_jinja_available():
          import jinja2
      else:
          raise ImportError(
              "Using RepoCard.from_template requires Jinja2 to be installed. Please"
              " install it with `pip install Jinja2`."
          )
  
      kwargs = card_data.to_dict().copy()
      kwargs.update(template_kwargs)  # Template_kwargs have priority
      template = jinja2.Template(
          Path(template_path or cls.default_template_path).read_text()
      )
      content = template.render(card_data=card_data.to_yaml(), **kwargs)
      return cls(content)
  
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 9 for calling the RepoCard obj's underlying member method code with example usage: obj.from_template(cls, card_data, template_path) and returns: cls