code: def create_model_card(args, model_name):
      if not is_jinja_available():
          raise ValueError(
              "Modelcard rendering is based on Jinja templates."
              " Please make sure to have `jinja` installed before using `create_model_card`."
              " To install it, please run `pip install Jinja2`."
          )
  
      if hasattr(args, "local_rank") and args.local_rank not in [-1, 0]:
          return
  
      hub_token = args.hub_token if hasattr(args, "hub_token") else None
      repo_name = get_full_repo_name(model_name, token=hub_token)
  
      model_card = ModelCard.from_template(
          card_data=ModelCardData(  # Card metadata object that will be converted to YAML block
              language="en",
              license="apache-2.0",
              library_name="diffusers",
              tags=[],
              datasets=args.dataset_name,
              metrics=[],
          ),
          template_path=MODEL_CARD_TEMPLATE_PATH,
          model_name=model_name,
          repo_name=repo_name,
          dataset_name=args.dataset_name
          if hasattr(args, "dataset_name")
          else None,
          learning_rate=args.learning_rate,
          train_batch_size=args.train_batch_size,
          eval_batch_size=args.eval_batch_size,
          gradient_accumulation_steps=(
              args.gradient_accumulation_steps
              if hasattr(args, "gradient_accumulation_steps")
              else None
          ),
          adam_beta1=args.adam_beta1
          if hasattr(args, "adam_beta1")
          else None,
          adam_beta2=args.adam_beta2
          if hasattr(args, "adam_beta2")
          else None,
          adam_weight_decay=args.adam_weight_decay
          if hasattr(args, "adam_weight_decay")
          else None,
          adam_epsilon=args.adam_epsilon
          if hasattr(args, "adam_epsilon")
          else None,
          lr_scheduler=args.lr_scheduler
          if hasattr(args, "lr_scheduler")
          else None,
          lr_warmup_steps=args.lr_warmup_steps
          if hasattr(args, "lr_warmup_steps")
          else None,
          ema_inv_gamma=args.ema_inv_gamma
          if hasattr(args, "ema_inv_gamma")
          else None,
          ema_power=args.ema_power
          if hasattr(args, "ema_power")
          else None,
          ema_max_decay=args.ema_max_decay
          if hasattr(args, "ema_max_decay")
          else None,
          mixed_precision=args.mixed_precision,
      )
  
      card_path = os.path.join(args.output_dir, "README.md")
      model_card.save(card_path)
  
imports: import os
  import re
  import sys
  import tempfile
  import traceback
  import warnings
  from pathlib import Path
  from typing import Dict, Optional, Union
  from uuid import uuid4
  from huggingface_hub import HfFolder, ModelCard, ModelCardData, create_repo, hf_hub_download, upload_folder, whoami
  from huggingface_hub.file_download import REGEX_COMMIT_HASH
  from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError, is_jinja_available
  from packaging import version
  from requests import HTTPError
  from ..None import __version__
  from .constants import DEPRECATED_REVISION_ARGS, DIFFUSERS_CACHE, HUGGINGFACE_CO_RESOLVE_ENDPOINT, SAFETENSORS_WEIGHTS_NAME, WEIGHTS_NAME
  from .import_utils import ENV_VARS_TRUE_VALUES, _flax_version, _jax_version, _onnxruntime_version, _torch_version, is_flax_available, is_onnx_available, is_torch_available
  from .logging import get_logger
label_desc: Use image node_id 3 for calling a global function with example usage: create_model_card(args, model_name) without return types