code: def collect_and_shape_result(c_load, g_load):
      # c_load : float e.g. 58.5
      # g_load : [[nvidia_device_id, gpu_load]]
  
      comm = current_communicator()
      if comm:
          res = [[comm.rank, c_load], *g_load[:1]]
          t_load_ndarray = np.array(res).reshape(-1)
  
          load_var = nn.Variable(
              [
                  len(t_load_ndarray),
              ]
          )
          load_var.d = t_load_ndarray
          load_list_var = [
              nn.Variable(
                  [
                      len(t_load_ndarray),
                  ]
              )
              for _ in range(comm.size)
          ]
          comm.all_gather(
              load_var.data, [a.data for a in load_list_var]
          )
          result_arr = [
              [*np.round(a.d.astype(float), decimals=1)]
              for a in load_list_var
          ]
      else:
          res = [[0, c_load], *g_load[:1]]
          t_load_ndarray = np.round(
              np.array(res).reshape(-1), decimals=1
          )
          result_arr = [[*t_load_ndarray.astype(float)]]
  
      result_arr = sorted(result_arr, key=lambda x: x[0])
  
      return result_arr
  
imports: import os
  import re
  import timeit
  from contextlib import contextmanager
  import nnabla
  import nnabla.utils.callback
  import numpy
  from nnabla.config import nnabla_config
  from nnabla.logger import logger
  from nnabla.utils import nnabla_pb2
  from nnabla.utils.communicator_util import current_communicator
  from nnabla.utils.get_file_handle import get_file_handle_save, get_decorated_file_loader, load_files
  from contextlib import contextmanager
  import nnabla.logger
  from nnabla.lms import SwapInOutScheduler
label_desc: Use image node_id 5 for calling a global function with example usage: collect_and_shape_result(c_load, g_load) and returns: result_arr