class_docstr: ``TrainContext`` gives access to report training and validation metrics to the Determined master
  during trial tasks.
class_docstr_tok: ["``","TrainContext","``","gives","access","to","report","training","and","validation","metrics","to","the","Determined","master","during","trial","tasks","."]
docstr: Report trial metrics to the master.
  
  You can include a list of ``batch_metrics``.  Batch metrics are not be shown in the WebUI
  but may be accessed from the master using the CLI for post-processing.
docstr_tok: ["Report","trial","metrics","to","the","master",".","You","can","include","a","list","of","``","batch_metrics","``",".","Batch","metrics","are","not","be","shown","in","the","WebUI","but","may","be","accessed","from","the","master","using","the","CLI","for","post-processing","."]
code: def _report_trial_metrics(
      self,
      group: str,
      steps_completed: int,
      metrics: Dict[str, Any],
      batch_metrics: Optional[List[Dict[str, Any]]] = None,
  ) -> None:
      """
      Report trial metrics to the master.
  
      You can include a list of ``batch_metrics``.  Batch metrics are not be shown in the WebUI
      but may be accessed from the master using the CLI for post-processing.
      """
  
      reportable_metrics = metrics
      if group == util._LEGACY_VALIDATION:
          # keep the old behavior of filtering out some metrics for validations.
          serializable_metrics = self._get_serializable_metrics(metrics)
          reportable_metrics = {
              k: metrics[k] for k in serializable_metrics
          }
  
      v1metrics = bindings.v1Metrics(
          avgMetrics=reportable_metrics, batchMetrics=batch_metrics
      )
      v1TrialMetrics = bindings.v1TrialMetrics(
          metrics=v1metrics,
          stepsCompleted=steps_completed,
          trialId=self._trial_id,
          trialRunId=self._run_id,
      )
      body = bindings.v1ReportTrialMetricsRequest(
          metrics=v1TrialMetrics, group=group
      )
      bindings.post_ReportTrialMetrics(
          self._session, body=body, metrics_trialId=self._trial_id
      )
  
      # Also sync tensorboard (all metrics, not just json-serializable ones).
      if self._tensorboard_mode == core.TensorboardMode.AUTO:
          if self._tbd_writer:
              if group == util._LEGACY_VALIDATION:
                  self._tbd_writer.on_validation_step_end(
                      steps_completed, metrics
                  )
              elif group == util._LEGACY_TRAINING:
                  self._tbd_writer.on_train_step_end(
                      steps_completed, metrics, batch_metrics
                  )
          assert self._tensorboard_manager is not None
          self._tensorboard_manager.sync()
  
imports: import enum
  import logging
  import pathlib
  from typing import Any, Callable, Dict, List, Optional, Set
  import determined
  from determined import core, tensorboard
  from determined.common import api, util
  from determined.common.api import bindings, errors
label_desc: Use image node_id 4 for calling the TrainContext obj's underlying member method code with example usage: obj._report_trial_metrics(group, steps_completed, metrics, batch_metrics) without return types