class_docstr: The client side of :class:`TrialServer`.
class_docstr_tok: ["The","client","side","of",":","class",":","`","TrialServer","`","."]
code: def send_metric(
      self,
      type: Literal[
          "PERIODICAL", "FINAL"
      ],  # pylint: disable=redefined-builtin
      parameter_id: int | None,
      trial_job_id: str,
      sequence: int,
      value: TrialMetric,
  ) -> None:
      if trial_job_id != self._trial_id:
          _logger.warning(
              "Trial job id does not match: %s vs. %s. Metric will be ignored.",
              trial_job_id,
              self._trial_id,
          )
          return
      metric = {
          "parameter_id": parameter_id,
          "trial_job_id": trial_job_id,
          "type": type,
          "sequence": sequence,
          "value": nni.dump(
              value
          ),  # Pack the metric value, which will be unpacked by tuner.
      }
      command = MetricCommand(
          command_type="metric",
          id=trial_job_id,
          metric=nni.dump(metric),
      )
      response = requests.post(self._url + "/metric", json=command)
      if response.status_code != 200:
          _logger.error("Failed to send metric: %s", response)
  
file_path: nni/nni/contrib/training_service/trial_client.py
imports: from __future__ import annotations
  import logging
  from typing_extensions import Literal
  import requests
  import nni
  from nni.typehint import ParameterRecord, TrialMetric
  from nni.runtime.env_vars import trial_env_vars
  from nni.runtime.trial_command_channel import TrialCommandChannel
  from .trial_runner import TrialServerHandler
  from .typehint import MetricCommand
label_desc: Use image node_id 3 for calling the TrialClient obj's underlying member method code with example usage: obj.send_metric(type, parameter_id, trial_job_id, sequence, value) without return types