code: def save_model_card(
      args,
      repo_id: str,
      images=None,
      repo_folder=None,
  ):
      img_str = ""
      if len(images) > 0:
          image_grid = make_image_grid(
              images, 1, len(args.validation_prompts)
          )
          image_grid.save(
              os.path.join(repo_folder, "val_imgs_grid.png")
          )
          img_str += "![val_imgs_grid](./val_imgs_grid.png)\n"
  
      yaml = f"""
  ---
  license: creativeml-openrail-m
  base_model: {args.pretrained_model_name_or_path}
  datasets:
  - {args.dataset_name}
  tags:
  - stable-diffusion
  - stable-diffusion-diffusers
  - text-to-image
  - diffusers
  inference: true
  ---
      """
      model_card = f"""
  # Text-to-image finetuning - {repo_id}
  
  This pipeline was finetuned from **{args.pretrained_model_name_or_path}** on the **{args.dataset_name}** dataset. Below are some example images generated with the finetuned pipeline using the following prompts: {args.validation_prompts}: \n
  {img_str}
  
  ## Pipeline usage
  
  You can use the pipeline like so:
  
  ```python
  from diffusers import DiffusionPipeline
  import torch
  
  pipeline = DiffusionPipeline.from_pretrained("{repo_id}", torch_dtype=torch.float16)
  prompt = "{args.validation_prompts[0]}"
  image = pipeline(prompt).images[0]
  image.save("my_image.png")
  ```
  
  ## Training info
  
  These are the key hyperparameters used during training:
  
  * Epochs: {args.num_train_epochs}
  * Learning rate: {args.learning_rate}
  * Batch size: {args.train_batch_size}
  * Gradient accumulation steps: {args.gradient_accumulation_steps}
  * Image resolution: {args.resolution}
  * Mixed-precision: {args.mixed_precision}
  
  """
      wandb_info = ""
      if is_wandb_available():
          wandb_run_url = None
          if wandb.run is not None:
              wandb_run_url = wandb.run.url
  
      if wandb_run_url is not None:
          wandb_info = f"""
  More information on all the CLI arguments and the environment are available on your [`wandb` run page]({wandb_run_url}).
  """
  
      model_card += wandb_info
  
      with open(os.path.join(repo_folder, "README.md"), "w") as f:
          f.write(yaml + model_card)
  
imports: import argparse
  import logging
  import math
  import os
  import random
  import shutil
  from pathlib import Path
  import accelerate
  import datasets
  import numpy
  import torch
  import torch.nn.functional
  import torch.utils.checkpoint
  import transformers
  from accelerate import Accelerator
  from accelerate.logging import get_logger
  from accelerate.state import AcceleratorState
  from accelerate.utils import ProjectConfiguration, set_seed
  from datasets import load_dataset
  from huggingface_hub import create_repo, upload_folder
  from packaging import version
  from torchvision import transforms
  from tqdm.auto import tqdm
  from transformers import CLIPTextModel, CLIPTokenizer
  from transformers.utils import ContextManagers
  import diffusers
  from diffusers import AutoencoderKL, DDPMScheduler, StableDiffusionPipeline, UNet2DConditionModel
  from diffusers.optimization import get_scheduler
  from diffusers.training_utils import EMAModel, compute_snr
  from diffusers.utils import check_min_version, deprecate, is_wandb_available, make_image_grid
  from diffusers.utils.import_utils import is_xformers_available
  from diffusers.utils.torch_utils import is_compiled_module
label_desc: Use image node_id 1 for calling a global function with example usage: save_model_card(args, repo_id, images, repo_folder) without return types