code: def native_op_vs_composed_ops(
      batch_size, num_classes, num_samples, num_iters
  ):
      np.random.seed(1618)  # Make it reproducible.
      shape = [batch_size, num_classes]
      logits_np = np.random.randn(*shape).astype(np.float32)
  
      # No CSE/CF.
      optimizer_options = config_pb2.OptimizerOptions(
          opt_level=config_pb2.OptimizerOptions.L0
      )
      config = config_pb2.ConfigProto(
          graph_options=config_pb2.GraphOptions(
              optimizer_options=optimizer_options
          )
      )
  
      with session.Session(config=config) as sess:
          logits = constant_op.constant(logits_np, shape=shape)
          native_op = control_flow_ops.group(
              native_sampler(logits, num_samples)
          )
          composed_op = control_flow_ops.group(
              composed_sampler(logits, num_samples)
          )
  
          native_dt = timeit.timeit(
              lambda: sess.run(native_op), number=num_iters
          )
          composed_dt = timeit.timeit(
              lambda: sess.run(composed_op), number=num_iters
          )
          return native_dt, composed_dt
  
imports: import collections
  import timeit
  import numpy
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling a global function with example usage: native_op_vs_composed_ops(batch_size, num_classes, num_samples, num_iters) and returns: native_dt,  composed_dt