code: def print_json_dist(message, ranks=None, path=None):
      from deepspeed import comm as dist
  
      """Print 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)
          path (str)
  
      """
      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:
          message["rank"] = my_rank
          import json
  
          with open(path, "w") as outfile:
              json.dump(message, outfile)
              os.fsync(outfile)
  
file_path: deepspeed/deepspeed/utils/logging.py
imports: import functools
  import logging
  import sys
  import os
label_desc: Use image node_id 4 for calling a global function with example usage: print_json_dist(message, ranks, path) without return types