code: def timed_op(func):
      def log_wrapper(*args, **kwargs):
          # Add enabled flag so that overhead to each comm op is two if conditions at most
          if comms_logger.enabled:
              if (
                  ("prof" in kwargs and kwargs["prof"])
                  or comms_logger.prof_all
                  or (
                      "log_name" in kwargs
                      and kwargs["log_name"] in comms_logger.prof_ops
                  )
              ):
                  # Need func args for their defaults
                  func_args = get_default_args(func)
                  func_args.update(kwargs)
                  msg_size = get_msg_size_from_args(
                      func, *args, **kwargs
                  )
                  log_name = get_debug_log_name(
                      func_args, comms_logger.debug
                  )
                  timers(log_name).start()
          # Return the op, then stop the op's timer
          try:
              return func(*args, **kwargs)
          finally:
              if comms_logger.enabled:
                  # Need to make op blocking for accurate logging
                  get_accelerator().synchronize()
                  # If we're using MPI, we can't simply sync the stream
                  if cdb.using_mpi:
                      cdb.barrier()
                  if (
                      ("prof" in kwargs and kwargs["prof"])
                      or comms_logger.prof_all
                      or (
                          "log_name" in kwargs
                          and kwargs["log_name"]
                          in comms_logger.prof_ops
                      )
                  ):
                      log_name = get_debug_log_name(
                          func_args, comms_logger.debug
                      )
                      raw_name = func.__name__
                      timers(log_name).stop()
                      # need temp var since 'elapsed' resets events
                      time_elapsed = timers(log_name).elapsed(
                          reset=False
                      )
                      comms_logger.append(
                          raw_name, log_name, time_elapsed, msg_size
                      )
  
      return log_wrapper
  
imports: import torch
  import os
  from ..constants import TORCH_DISTRIBUTED_DEFAULT_PORT, default_pg_timeout
  from .constants import *
  from .reduce_op import *
  from deepspeed.accelerator import get_accelerator
  from deepspeed.comm.ccl import CCLBackend
  from deepspeed.utils.comms_logging import CommsLogger
  from deepspeed.utils import timer, get_caller_func
  from deepspeed.comm.torch import TorchBackend
  from deepspeed import utils
  from datetime import timedelta
  from deepspeed.comm.utils import *
label_desc: Use image node_id 3 for calling a global function with example usage: timed_op(func) and returns: log_wrapper, func