code: def main():
      parser = argparse.ArgumentParser(
          description="Amulet training service trial runner"
      )
      parser.add_argument(
          "channel",
          type=str,
          help="The path where file channel is mounted (in cluster container)",
      )
      parser.add_argument(
          "out",
          type=str,
          default=None,
          help="Checkpoint directory of the trial runner. If specified, trial runner will try to find its checkpoint.",
      )
      parser.add_argument(
          "--rank",
          type=int,
          default=None,
          help="Rank of trial runner. Meaningful for distributed training. "
          "If not set, will try to read from environment variable `RANK`.",
      )
      parser.add_argument(
          "--interval",
          type=float,
          default=60.0,
          help="Interval (seconds) between two polls of the channel",
      )
      parser.add_argument(
          "--heartbeat-max-interval",
          type=float,
          default=600.0,
          help="Max interval (seconds) between two heartbeats. "
          "Heartbeat is used to tell the manager that the runner is still alive. "
          "The initial heartbeat interval is `interval`. "
          "It will be exponentially increased until it reaches this value if no message from manager is received.",
      )
      parser.add_argument(
          "--patience",
          type=float,
          default=1800.0,
          help="Number of seconds without any updates or running trials before the runner shutdowns",
      )
      parser.add_argument(
          "--log-buffer-size",
          type=int,
          default=0,
          help="Buffer size for trial stdout. See bufsize in `subprocess.Popen`.",
      )
  
      args = parser.parse_args()
      if args.rank is None:
          args.rank = int(os.environ.get("RANK", 0))
      trial_runner_loop(**vars(args))
  
imports: from __future__ import annotations
  import atexit
  import argparse
  import json
  import logging
  import os
  import subprocess
  import sys
  import threading
  import time
  from collections import deque
  from functools import partial
  from http.server import BaseHTTPRequestHandler, HTTPServer
  from pathlib import Path
  from typing import Sequence, Callable
  from .file_channel import FileChannel
  from .typehint import CreateCommand, KillCommand, MetricCommand, TrialStatusCommand, WakeUpCommand, ReportAwakeCommand, Trial, Status, typed_dict_validation
  from .utils import graceful_kill, add_handler
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types