code: def agent_up(
      master_host: str,
      master_port: int,
      agent_config_path: Optional[pathlib.Path],
      agent_name: str,
      agent_resource_pool: Optional[str],
      image_repo_prefix: Optional[str],
      version: Optional[str],
      gpu: bool,
      autorestart: bool,
      cluster_name: str,
      labels: Optional[Dict] = None,
  ) -> None:
      agent_conf = {}
      volumes = ["/var/run/docker.sock:/var/run/docker.sock"]
      if agent_config_path is not None:
          with agent_config_path.open() as f:
              agent_conf = util.yaml_safe_load(f)
          volumes += [
              f"{os.path.abspath(agent_config_path)}:/etc/determined/agent.yaml"
          ]
  
      # Fallback on agent config for options not specified as flags.
      environment = {}
      if agent_name == AGENT_NAME_DEFAULT:
          agent_name = agent_conf.get("agent_id", agent_name)
      else:
          environment["DET_AGENT_ID"] = agent_name
      environment["DET_MASTER_PORT"] = str(master_port)
      if master_port == MASTER_PORT_DEFAULT:
          if "master_port" in agent_conf:
              del environment["DET_MASTER_PORT"]
              master_port = agent_conf["master_port"]
  
      if agent_resource_pool is not None:
          environment["DET_RESOURCE_POOL"] = agent_resource_pool
  
      _wait_for_master(master_host, master_port, cluster_name)
  
      if master_host == "localhost":
          master_host = get_proxy_addr()
      environment["DET_MASTER_HOST"] = master_host
  
      image = f"{image_repo_prefix}/determined-agent:{version}"
      init = True
      mounts = []  # type: List[str]
      if labels is None:
          labels = {}
      labels["ai.determined.type"] = "agent"
  
      restart_policy = (
          {"Name": "unless-stopped"} if autorestart else None
      )
      device_requests = [GPU_DEVICE_REQUEST] if gpu else None
  
      client = docker_client()
      print(f"Starting {agent_name}")
      client.containers.run(
          image=image,
          environment=environment,
          init=init,
          mounts=mounts,
          volumes=volumes,
          network_mode="host",
          name=agent_name,
          detach=True,
          labels=labels,
          restart_policy=restart_policy,
          device_requests=device_requests,
      )
  
imports: import contextlib
  import os
  import pathlib
  import re
  import socket
  import subprocess
  import sys
  import tempfile
  import threading
  import time
  from typing import Any, Callable, Dict, Generator, List, Optional, Sequence, Type
  import appdirs
  import docker
  from determined.common import constants, util
  from determined.deploy.errors import MasterTimeoutExpired
  from determined.deploy.healthcheck import wait_for_master
label_desc: Use image node_id 15 for calling a global function with example usage: agent_up(master_host, master_port, agent_config_path, agent_name, agent_resource_pool, image_repo_prefix, version, gpu, autorestart, cluster_name, labels) without return types