code: def list(
      ctx,
      pathspec=None,
      hash=None,
      type=None,
      id=None,
      follow_resumed=False,
      as_json=False,
      file=None,
  ):
      card_id = id
      if pathspec is None:
          list_many_cards(
              ctx,
              type=type,
              hash=hash,
              card_id=card_id,
              follow_resumed=follow_resumed,
              as_json=as_json,
              file=file,
          )
          return
  
      available_card_paths, card_datastore, pathspec = resolve_card(
          ctx,
          pathspec,
          type=type,
          hash=hash,
          card_id=card_id,
          follow_resumed=follow_resumed,
          no_echo=as_json,
      )
      list_available_cards(
          ctx,
          pathspec,
          available_card_paths,
          card_datastore,
          command=None,
          show_list_as_json=as_json,
          file=file,
      )
  
imports: from metaflow.client import Task
  from metaflow import JSONType, namespace
  from metaflow.util import resolve_identity
  from metaflow.exception import CommandException, MetaflowNotFound, MetaflowNamespaceMismatch
  import webbrowser
  import re
  from metaflow._vendor import click
  import os
  import json
  import uuid
  import signal
  import random
  from contextlib import contextmanager
  from functools import wraps
  from metaflow.exception import MetaflowNamespaceMismatch
  from .card_datastore import CardDatastore, NUM_SHORT_HASH_CHARS
  from .exception import CardClassFoundException, IncorrectCardArgsException, UnrenderableCardException, CardNotPresentException, TaskNotFoundException
  import traceback
  from collections import namedtuple
  from .card_resolver import resolve_paths_from_task, resumed_info
label_desc: Use image node_id 16 for calling a global function with example usage: list(ctx, pathspec, hash, type, id, follow_resumed, as_json, file) without return types