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","."]
code: def _get_serializable_metrics(
      self, metrics: Dict[str, Any]
  ) -> Set[str]:
      serializable_metrics = set()
      non_serializable_metrics = set()
  
      # In the case of trial implementation bugs, validation metric functions may return None.
      # Immediately fail any trial that encounters a None metric.
      for metric_name, metric_value in metrics.items():
          if metric_value is None:
              raise RuntimeError(
                  "Validation metric '{}' returned "
                  "an invalid scalar value: {}".format(
                      metric_name, metric_value
                  )
              )
  
          if isinstance(metric_value, (bytes, bytearray)):
              non_serializable_metrics.add(metric_name)
          else:
              serializable_metrics.add(metric_name)
  
      if len(non_serializable_metrics):
          logger.warning(
              "Removed non serializable metrics: %s",
              ", ".join(non_serializable_metrics),
          )
  
      return serializable_metrics
  
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 10 for calling the TrainContext obj's underlying member method code with example usage: obj._get_serializable_metrics(metrics) and returns: serializable_metrics