code: def _get_cluster_spec(sorted_cluster_info):
      """Given a list of node metadata sorted by executor_id, returns a tensorflow cluster_spec"""
      cluster_spec = {}
      last_executor_id = -1
      for node in sorted_cluster_info:
          if node["executor_id"] == last_executor_id:
              raise Exception("Duplicate worker/task in cluster_info")
          last_executor_id = node["executor_id"]
          logger.info("node: {0}".format(node))
          (njob, nhost, nport) = (
              node["job_name"],
              node["host"],
              node["port"],
          )
          hosts = [] if njob not in cluster_spec else cluster_spec[njob]
          hosts.append("{0}:{1}".format(nhost, nport))
          cluster_spec[njob] = hosts
      return cluster_spec
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import nested_scopes
  from __future__ import print_function
  import json
  import logging
  import multiprocessing
  import os
  import pkg_resources
  import platform
  import socket
  import subprocess
  import sys
  import uuid
  import time
  import traceback
  from packaging import version
  from threading import Thread
  from .None import TFManager
  from .None import TFNode
  from .None import gpu_info
  from .None import marker
  from .None import reservation
  from .None import util
label_desc: Use image node_id 2 for calling a global function with example usage: _get_cluster_spec(sorted_cluster_info) and returns: cluster_spec