code: def enable_collective_ops():
      """Enable collectives in the current process."""
      cluster_resolver = cluster_resolver_lib.TFConfigClusterResolver()
      context.context().configure_collective_ops(
          collective_leader="'/job:worker/replica:0/task:0'"
      )
      config_proto = config_pb2.ConfigProto()
      config_proto.experimental.collective_group_leader = (
          "/job:worker/replica:0/task:0"
      )
      server_def = tensorflow_server_pb2.ServerDef(
          cluster=cluster_resolver.cluster_spec().as_cluster_def(),
          default_session_config=config_proto,
          job_name=cluster_resolver.task_type,
          task_index=cluster_resolver.task_id,
          protocol=cluster_resolver.rpc_layer,
      )
      context.context().enable_collective_ops(server_def)
      # Recover default flag values.
      CollectiveReplicaLauncher._prefer_unique_instance_key = True
      CollectiveReplicaLauncher._prefer_ordering_token = False
  
imports: import collections
  import os
  import threading
  import time
  from absl.testing import parameterized
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.core.protobuf import tensorflow_server_pb2
  from tensorflow.python.distribute import cluster_resolver
  from tensorflow.python.distribute import collective_util
  from tensorflow.python.distribute import combinations
  from tensorflow.python.distribute import cross_device_ops
  from tensorflow.python.distribute import cross_device_utils
  from tensorflow.python.distribute import device_util
  from tensorflow.python.distribute import multi_process_runner
  from tensorflow.python.distribute import multi_worker_test_base
  from tensorflow.python.distribute import reduce_util
  from tensorflow.python.distribute import test_util
  from tensorflow.python.distribute import values
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import test
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import collective_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import math_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 2 for calling a global function with example usage: enable_collective_ops() without return types