code: def _reduce_metrics(
      batch_processor_context: TorchBatchProcessorContext,
      core_context: core.Context,
      rank: int,
      steps_completed: int,
  ) -> None:
      reducables = list(batch_processor_context._wrapped_reducers)
      # If the user has set metric reducers
      if len(reducables) > 0:
          # Reduce metrics (blocking as reduce across slots is needed)
          # Report reduced metrics to master
          gatherables = [
              wrapped.per_slot_reduce() for wrapped in reducables
          ]
          if rank == 0:
              gathered = core_context.distributed.gather(gatherables)
              if gathered is not None:
                  metrics = (
                      batch_processor_context.run_cross_slot_reduction(
                          reducables, gathered
                      )
                  )
                  core_context.train.report_validation_metrics(
                      steps_completed=steps_completed,
                      metrics=metrics,
                  )
          else:
              # Other ranks sent metrics to chief
              core_context.distributed.gather(gatherables)
  
imports: import abc
  import json
  import logging
  import math
  import os
  import pathlib
  import uuid
  import warnings
  from typing import TYPE_CHECKING, Any, ContextManager, Dict, Optional, Set, Sized, Type
  import torch
  import torch.distributed
  from torch import nn
  from torch.utils import data
  import determined
  from determined import common, core, pytorch
label_desc: Use image node_id 10 for calling a global function with example usage: _reduce_metrics(batch_processor_context, core_context, rank, steps_completed) without return types