class_docstr: A server for trial to get parameters and report metrics to the trial runner.
class_docstr_tok: ["A","server","for","trial","to","get","parameters","and","report","metrics","to","the","trial","runner","."]
code: def __init__(
      self,
      trials: Sequence[Trial],
      on_metric: Callable[[MetricCommand], None],
      *args,
      **kwargs,
  ):
      self.trials = trials
      self.on_metric = on_metric
      # Must be before super.init. The handler will start to handle requests within super.init.
      super().__init__(*args, **kwargs)
  
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 1 to create a new TrialServerHandler object from inherited base classes: BaseHTTPRequestHandler with example: obj = TrialServerHandler(trials, on_metric)