code: def get_rank(cluster_info):
      # As task placement may not be identical between two different jobs,
      # we cannot simply index cluster_info using partitionId to get current
      # ip and port.
      # The approach here is to first get all tasks' ip in this job and compute
      # a local rank by counting how many tasks has the same ip but with lower id.
      # We then use the local rank to find the right slot in cluster_info to find
      # the right global_rank.
      from pyspark import BarrierTaskContext
  
      tc = BarrierTaskContext().get()
      infos = tc.getLocalProperty("addresses").split(",")
      idx = tc.partitionId()
      local_ip = infos[idx].split(":")[0]
      local_rank = 0
      for i in range(0, idx):
          if infos[i].startswith(local_ip):
              local_rank += 1
      global_rank = -1
      local_count = 0
      for node in cluster_info:
          if node.startswith(local_ip):
              local_count += 1
          global_rank += 1
          if local_count == local_rank + 1:
              break
      return global_rank
  
imports: from contextlib import closing
  import socket
  import sys
  import tempfile
  import shutil
  from bigdl.dllib.utils import log4Error
  from bigdl.dllib.utils.common import callBigDlFunc
  from bigdl.dllib.utils.file_utils import get_file_list, is_local_path
  from bigdl.orca.data import SparkXShards
  from bigdl.orca.data.utils import get_size
  from bigdl.orca.data.file import put_local_dir_tree_to_remote, put_local_file_to_remote, get_remote_file_to_local, get_remote_dir_to_local
  from bigdl.dllib.utils.utils import convert_row_to_numpy
  from functools import partial
  import numpy
  from bigdl.orca.common import SafePickle
  import os
  import subprocess
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 30 for calling a global function with example usage: get_rank(cluster_info) and returns: global_rank