class_docstr: The BatchMetricsLogger will log metrics in batch against an mlflow run.
  If run_id is passed to to constructor then all recording and logging will
  happen against that run_id.
  If no run_id is passed into constructor, then the run ID will be fetched
  from `mlflow.active_run()` each time `record_metrics()` or `flush()` is called; in this
  case, callers must ensure that an active run is present before invoking
  `record_metrics()` or `flush()`.
class_docstr_tok: ["The","BatchMetricsLogger","will","log","metrics","in","batch","against","an","mlflow","run",".","If","run_id","is","passed","to","to","constructor","then","all","recording","and","logging","will","happen","against","that","run_id",".","If","no","run_id","is","passed","into","constructor",",","then","the","run","ID","will","be","fetched","from","`","mlflow.active_run","(",")","`","each","time","`","record_metrics","(",")","`","or","`","flush","(",")","`","is","called",";","in","this","case",",","callers","must","ensure","that","an","active","run","is","present","before","invoking","`","record_metrics","(",")","`","or","`","flush","(",")","`","."]
docstr: Submit a set of metrics to be logged. The metrics may not be immediately logged, as this
  class will batch them in order to not increase execution time too much by logging
  frequently.
  
  Args:
      metrics: Dictionary containing key, value pairs of metrics to be logged.
      step: The training step that the metrics correspond to.
docstr_tok: ["Submit","a","set","of","metrics","to","be","logged",".","The","metrics","may","not","be","immediately","logged",",","as","this","class","will","batch","them","in","order","to","not","increase","execution","time","too","much","by","logging","frequently",".","Args",":","metrics",":","Dictionary","containing","key",",","value","pairs","of","metrics","to","be","logged",".","step",":","The","training","step","that","the","metrics","correspond","to","."]
code: def record_metrics(self, metrics, step=None):
      """
      Submit a set of metrics to be logged. The metrics may not be immediately logged, as this
      class will batch them in order to not increase execution time too much by logging
      frequently.
  
      Args:
          metrics: Dictionary containing key, value pairs of metrics to be logged.
          step: The training step that the metrics correspond to.
      """
      current_timestamp = time.time()
      if self.previous_training_timestamp is None:
          self.previous_training_timestamp = current_timestamp
  
      training_time = (
          current_timestamp - self.previous_training_timestamp
      )
  
      self.total_training_time += training_time
  
      # log_batch() requires step to be defined. Therefore will set step to 0 if not defined.
      if step is None:
          step = 0
  
      for key, value in metrics.items():
          self.data.append(
              Metric(key, value, int(current_timestamp * 1000), step)
          )
  
      if self._should_flush():
          self.flush()
  
      self.previous_training_timestamp = current_timestamp
  
imports: import contextlib
  import inspect
  import logging
  import time
  from typing import List
  import mlflow
  from mlflow.entities import Metric
  from mlflow.tracking.client import MlflowClient
  from mlflow.utils.validation import MAX_METRICS_PER_BATCH
  from mlflow.utils.autologging_utils.client import MlflowAutologgingQueueingClient
  from mlflow.utils.autologging_utils.events import AutologgingEventLogger
  from mlflow.utils.autologging_utils.logging_and_warnings import set_mlflow_events_and_warnings_behavior_globally, set_non_mlflow_warnings_behavior_for_current_thread
  from mlflow.utils.autologging_utils.safety import ExceptionSafeAbstractClass, ExceptionSafeClass, PatchFunction, exception_safe_function_for_class, is_testing, picklable_exception_safe_function, revert_patches, safe_patch, update_wrapper_extended, with_managed_run
  from mlflow.utils.autologging_utils.versioning import FLAVOR_TO_MODULE_NAME_AND_VERSION_INFO_KEY, get_min_max_version_and_pip_release, is_flavor_supported_for_associated_package_versions
label_desc: Use image node_id 5 for calling the BatchMetricsLogger obj's underlying member method code with example usage: obj.record_metrics(metrics, step) without return types