code: def download_mmar(
      item: str | Mapping,
      mmar_dir: PathLike | None = None,
      progress: bool = True,
      api: bool = True,
      version: int = -1,
  ) -> Path:
      """
      Download and extract Medical Model Archive (MMAR) from Nvidia Clara Train.
  
      See Also:
          - https://docs.nvidia.com/clara/
          - Nvidia NGC Registry CLI
          - https://docs.nvidia.com/clara/clara-train-sdk/pt/mmar.html
  
      Args:
          item: the corresponding model item from `MODEL_DESC`.
            Or when api is True, the substring to query NGC's model name field.
          mmar_dir: target directory to store the MMAR, default is `mmars` subfolder under `torch.hub get_dir()`.
          progress: whether to display a progress bar.
          api: whether to query NGC and download via api
          version: which version of MMAR to download.  -1 means the latest from ngc.
  
      Examples::
          >>> from monai.apps import download_mmar
          >>> download_mmar("clara_pt_prostate_mri_segmentation_1", mmar_dir=".")
          >>> download_mmar("prostate_mri_segmentation", mmar_dir=".", api=True)
  
  
      Returns:
          The local directory of the downloaded model.
          If api is True, a list of local directories of downloaded models.
      """
      if not mmar_dir:
          get_dir, has_home = optional_import(
              "torch.hub", name="get_dir"
          )
          if has_home:
              mmar_dir = Path(get_dir()) / "mmars"
          else:
              raise ValueError(
                  "mmar_dir=None, but no suitable default directory computed. Upgrade Pytorch to 1.6+ ?"
              )
      _mmar_dir = Path(mmar_dir)
      model_dir: Path
      if api:
          model_dict = _get_all_ngc_models(
              item.get(Keys.NAME, f"{item}")
              if isinstance(item, Mapping)
              else f"{item}"
          )
          if len(model_dict) == 0:
              raise ValueError(
                  f"api query returns no item for pattern {item}.  Please change or shorten it."
              )
          model_dir_list: list[Path] = []
          for k, v in model_dict.items():
              ver = v["latest"] if version == -1 else str(version)
              download_url = _get_ngc_url(k, ver)
              model_dir = _mmar_dir / v["name"]
              download_and_extract(
                  url=download_url,
                  filepath=_mmar_dir / f'{v["name"]}_{ver}.zip',
                  output_dir=model_dir,
                  hash_val=None,
                  hash_type="md5",
                  file_type="zip",
                  has_base=False,
                  progress=progress,
              )
              model_dir_list.append(model_dir)
          if not model_dir_list:
              raise ValueError(
                  f"api query download no item for pattern {item}.  Please change or shorten it."
              )
          return model_dir_list[0]
  
      if not isinstance(item, Mapping):
          item = get_model_spec(item)
      ver = item.get(Keys.VERSION, 1)
      if version > 0:
          ver = str(version)
      model_fullname = f"{item[Keys.NAME]}_{ver}"
      model_dir = _mmar_dir / model_fullname
      model_url = item.get(Keys.URL) or _get_ngc_url(
          item[Keys.NAME], version=ver, model_prefix="nvidia/med/"
      )
      download_and_extract(
          url=model_url,
          filepath=_mmar_dir
          / f"{model_fullname}.{item[Keys.FILE_TYPE]}",
          output_dir=model_dir,
          hash_val=item[Keys.HASH_VAL],
          hash_type=item[Keys.HASH_TYPE],
          file_type=item[Keys.FILE_TYPE],
          has_base=False,
          progress=progress,
      )
      return model_dir
  
imports: from __future__ import annotations
  import json
  import os
  import warnings
  from collections.abc import Mapping
  from pathlib import Path
  from typing import Any
  import torch
  import monai.networks.nets
  from monai.apps.utils import download_and_extract, logger
  from monai.config.type_definitions import PathLike
  from monai.networks.utils import copy_model_state
  from monai.utils.module import optional_import
  from .model_desc import MODEL_DESC
  from .model_desc import RemoteMMARKeys
label_desc: Use image node_id 5 for calling a global function with example usage: download_mmar(item, mmar_dir, progress, api, version) and returns: model_dir, model_dir_list