code: def list_agents(args: argparse.Namespace) -> None:
      resp = bindings.get_GetAgents(cli.setup_session(args))
  
      agents = [
          collections.OrderedDict(
              [
                  ("id", local_id(a.id)),
                  ("version", a.version),
                  (
                      "registered_time",
                      render.format_time(a.registeredTime),
                  ),
                  (
                      "num_slots",
                      len(a.slots) if a.slots is not None else "",
                  ),
                  (
                      "num_containers",
                      len(a.containers)
                      if a.containers is not None
                      else "",
                  ),
                  (
                      "resource_pools",
                      ", ".join(a.resourcePools)
                      if a.resourcePools is not None
                      else "",
                  ),
                  ("enabled", a.enabled),
                  ("draining", a.draining),
                  (
                      "addresses",
                      ", ".join(a.addresses)
                      if a.addresses is not None
                      else "",
                  ),
              ]
          )
          for a in sorted(
              resp.agents or [], key=operator.attrgetter("id")
          )
      ]
  
      if args.json:
          determined.cli.render.print_json(agents)
          return
  
      headers = [
          "Agent ID",
          "Version",
          "Registered Time",
          "Slots",
          "Containers",
          "Resource Pool",
          "Enabled",
          "Draining",
          "Addresses",
      ]
      values = [a.values() for a in agents]
      render.tabulate_or_csv(headers, values, args.csv)
  
file_path: determined/harness/determined/cli/agent.py
imports: import argparse
  import collections
  import operator
  import os
  import sys
  import typing
  from typing import Any, Callable, Dict, List
  import determined.cli.render
  from determined import cli
  from determined.cli import errors, render
  from determined.cli import task
  from determined.common import api, check
  from determined.common.api import authentication, bindings
  from determined.common.declarative_argparse import Arg, Cmd, Group
label_desc: Use image node_id 2 for calling a global function with example usage: list_agents(args) without return types