code: def list_models(
      repo: str = "onnx/models:main",
      model: Optional[str] = None,
      tags: Optional[List[str]] = None,
  ) -> List[ModelInfo]:
      """Gets the list of model info consistent with a given name and tags
  
      Args:
          repo: The location of the model repo in format
              "user/repo[:branch]". If no branch is found will default to
              "main"
          model: The name of the model to search for. If `None`, will
              return all models with matching tags.
          tags: A list of tags to filter models by. If `None`, will return
              all models with matching name.
  
      Returns:
          ``ModelInfo``s.
      """
      base_url = _get_base_url(repo)
      manifest_url = base_url + "ONNX_HUB_MANIFEST.json"
      try:
          with urlopen(manifest_url) as response:
              manifest: List[ModelInfo] = [
                  ModelInfo(info)
                  for info in json.load(cast(IO[str], response))
              ]
      except HTTPError as e:
          raise AssertionError(
              f"Could not find manifest at {manifest_url}"
          ) from e
  
      # Filter by model name first.
      matching_models = (
          manifest
          if model is None
          else [m for m in manifest if m.model.lower() == model.lower()]
      )
  
      # Filter by tags
      if tags is None:
          return matching_models
  
      canonical_tags = {t.lower() for t in tags}
      matching_info_list: List[ModelInfo] = []
      for m in matching_models:
          model_tags = {t.lower() for t in m.tags}
          if len(canonical_tags.intersection(model_tags)) > 0:
              matching_info_list.append(m)
      return matching_info_list
  
imports: import hashlib
  import json
  import os
  import sys
  import tarfile
  from io import BytesIO
  from os.path import join
  from typing import IO, Any, Dict, List, Optional, Set, Tuple, cast
  from urllib.error import HTTPError
  from urllib.request import urlopen
  import onnx
label_desc: Use image node_id 7 for calling a global function with example usage: list_models(repo, model, tags) and returns: matching_info_list, matching_models