code: def write_model_card(
      hf_model_name: str,
      repo_root=DEFAULT_REPO,
      save_dir=Path("marian_converted"),
      dry_run=False,
      extra_metadata={},
  ) -> str:
      """
      Copy the most recent model's readme section from opus, and add metadata. upload command: aws s3 sync model_card_dir
      s3://models.huggingface.co/bert/Helsinki-NLP/ --dryrun
      """
      import pandas as pd
  
      hf_model_name = remove_prefix(hf_model_name, ORG_NAME)
      opus_name: str = convert_hf_name_to_opus_name(hf_model_name)
      if repo_root not in ("OPUS-MT-train", "Tatoeba-Challenge"):
          raise ValueError(
              f"Repos root is {repo_root}. Expected either OPUS-MT-train or Tatoeba-Challenge"
          )
      opus_readme_path = Path(repo_root).joinpath(
          "models", opus_name, "README.md"
      )
      if not (opus_readme_path.exists()):
          raise ValueError(f"Readme file {opus_readme_path} not found")
  
      opus_src, opus_tgt = [x.split("+") for x in opus_name.split("-")]
  
      readme_url = f"https://github.com/Helsinki-NLP/{repo_root}/tree/master/models/{opus_name}/README.md"
  
      s, t = ",".join(opus_src), ",".join(opus_tgt)
      metadata = {
          "hf_name": hf_model_name,
          "source_languages": s,
          "target_languages": t,
          "opus_readme_url": readme_url,
          "original_repo": repo_root,
          "tags": ["translation"],
      }
      metadata.update(extra_metadata)
      metadata.update(get_system_metadata(repo_root))
  
      # combine with opus markdown
  
      extra_markdown = (
          f"### {hf_model_name}\n\n* source group: {metadata['src_name']} \n* target group: "
          f"{metadata['tgt_name']} \n*  OPUS readme: [{opus_name}]({readme_url})\n"
      )
  
      content = opus_readme_path.open().read()
      content = content.split("\n# ")[
          -1
      ]  # Get the lowest level 1 header in the README -- the most recent model.
      splat = content.split("*")[2:]
      print(splat[3])
      content = "*".join(splat)
      content = (
          FRONT_MATTER_TEMPLATE.format(metadata["src_alpha2"])
          + extra_markdown
          + "\n* "
          + content.replace("download", "download original weights")
      )
  
      items = "\n\n".join([f"- {k}: {v}" for k, v in metadata.items()])
      sec3 = "\n### System Info: \n" + items
      content += sec3
      if dry_run:
          return content, metadata
      sub_dir = save_dir / f"opus-mt-{hf_model_name}"
      sub_dir.mkdir(exist_ok=True)
      dest = sub_dir / "README.md"
      dest.open("w").write(content)
      pd.Series(metadata).to_json(sub_dir / "metadata.json")
  
      # if dry_run:
      return content, metadata
  
imports: import argparse
  import json
  import os
  import socket
  import time
  import warnings
  from pathlib import Path
  from typing import Dict, List, Union
  from zipfile import ZipFile
  import numpy
  import torch
  from torch import nn
  from tqdm import tqdm
  from huggingface_hub.hf_api import list_models
  from transformers import MarianConfig, MarianMTModel, MarianTokenizer
label_desc: Use image node_id 14 for calling a global function with example usage: write_model_card(hf_model_name, repo_root, save_dir, dry_run, extra_metadata) and returns: content,  metadata, content,  metadata