code: def log_scalar_metric(self, metric_name, value, step=None):
          
          if opt.has_numpy:
              np = opt.np
              if isinstance(value, np.generic):
                  value = np.asscalar(value)
              if isinstance(step, np.generic):
                  step = np.asscalar(step)
          if step is None:
              step = self._metric_step_counter.get(metric_name, -1) + 1
          self._logged_metrics.put(
              ScalarMetricLogEntry(metric_name, step,
                                   datetime.datetime.utcnow(),
                                   value))
          self._metric_step_counter[metric_name] = step
docs: Add a new measurement.
  
          The measurement will be processed by the MongoDB observer
          during a heartbeat event.
          Other observers are not yet supported.
  
          :param metric_name: The name of the metric, e.g. training.loss.
          :param value: The measured value.
          :param step: The step number (integer), e.g. the iteration number
                      If not specified, an internal counter for each metric
                      is used, incremented by one.