code: def _get_all_ngc_models(pattern, page_index=0, page_size=50):
      url = (
          "https://api.ngc.nvidia.com/v2/search/catalog/resources/MODEL"
      )
      query_dict = {
          "query": "",
          "orderBy": [{"field": "score", "value": "DESC"}],
          "queryFields": [
              "all",
              "description",
              "displayName",
              "name",
              "resourceId",
          ],
          "fields": [
              "isPublic",
              "attributes",
              "guestAccess",
              "name",
              "orgName",
              "teamName",
              "displayName",
              "dateModified",
              "labels",
              "description",
          ],
          "page": 0,
      }
  
      filter = [dict(field="name", value=f"*{pattern}*")]
      query_dict["page"] = page_index
      query_dict["pageSize"] = page_size
      query_dict["filters"] = filter
      query_str = json.dumps(query_dict)
      full_url = f"{url}?q={query_str}"
      requests_get, has_requests = optional_import(
          "requests", name="get"
      )
      if has_requests:
          resp = requests_get(full_url)
          resp.raise_for_status()
      else:
          raise ValueError(
              "NGC API requires requests package.  Please install it."
          )
      model_list = json.loads(resp.text)
      model_dict = {}
      for result in model_list["results"]:
          for model in result["resources"]:
              current_res_id = model["resourceId"]
              model_dict[current_res_id] = {"name": model["name"]}
              for attribute in model["attributes"]:
                  if attribute["key"] == "latestVersionIdStr":
                      model_dict[current_res_id]["latest"] = attribute[
                          "value"
                      ]
      return model_dict
  
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 2 for calling a global function with example usage: _get_all_ngc_models(pattern, page_index, page_size) and returns: model_dict