code: def list_checkpoints(args: argparse.Namespace) -> None:
      if args.best:
          sorter = bindings.checkpointv1SortBy.SEARCHER_METRIC
      else:
          sorter = bindings.checkpointv1SortBy.END_TIME
      r = bindings.get_GetExperimentCheckpoints(
          cli.setup_session(args),
          id=args.experiment_id,
          limit=args.best,
          sortByAttr=sorter,
      )
      checkpoints = r.checkpoints
      searcher_metric = ""
      if len(checkpoints) > 0:
          config = checkpoints[0].training.experimentConfig or {}
          if "searcher" in config and "metric" in config["searcher"]:
              searcher_metric = str(config["searcher"]["metric"])
  
      def get_validation_metric(
          c: bindings.v1Checkpoint, metric: str
      ) -> str:
          if (
              c.training.validationMetrics
              and c.training.validationMetrics.avgMetrics
              and metric in c.training.validationMetrics.avgMetrics
          ):
              return str(
                  c.training.validationMetrics.avgMetrics[metric]
              )
          return ""
  
      headers = [
          "Trial ID",
          "# of Batches",
          "State",
          "Validation Metric",
          "UUID",
          "Resources",
          "Size",
      ]
      values = [
          [
              c.training.trialId,
              c.metadata.get("steps_completed", None),
              c.state,
              get_validation_metric(c, searcher_metric),
              c.uuid,
              render.format_resources(c.resources),
              render.format_resource_sizes(c.resources),
          ]
          for c in checkpoints
      ]
  
      render.tabulate_or_csv(headers, values, args.csv)
  
file_path: determined/harness/determined/cli/checkpoint.py
imports: import argparse
  import json
  from typing import Any, List, Optional
  from determined import cli, errors, experimental
  from determined.cli import render
  from determined.common.api import authentication, bindings
  from determined.common.declarative_argparse import Arg, Cmd
  from determined.experimental.client import DownloadMode
label_desc: Use image node_id 2 for calling a global function with example usage: list_checkpoints(args) and returns: str, str