code: def log_dist(message, ranks=None, level=logging.INFO):
      from deepspeed import comm as dist
  
      """Log message when one of following condition meets
  
      + not dist.is_initialized()
      + dist.get_rank() in ranks if ranks is not None or ranks = [-1]
  
      Args:
          message (str)
          ranks (list)
          level (int)
  
      """
      should_log = not dist.is_initialized()
      ranks = ranks or []
      my_rank = dist.get_rank() if dist.is_initialized() else -1
      if ranks and not should_log:
          should_log = ranks[0] == -1
          should_log = should_log or (my_rank in set(ranks))
      if should_log:
          final_message = "[Rank {}] {}".format(my_rank, message)
          logger.log(level, final_message)
  
file_path: DeepSpeed/deepspeed/utils/logging.py
imports: import functools
  import logging
  import sys
  import os
label_desc: Use image node_id 3 for calling a global function with example usage: log_dist(message, ranks, level) without return types