code: def _apply_with_random_selector(x, func, num_cases):
      """Computes func(x, sel), with sel sampled from [0...num_cases-1].
  
      Args:
        x: input Tensor.
        func: Python function to apply.
        num_cases: Python int32, number of cases to sample sel from.
  
      Returns:
        The result of func(x, sel), where func receives the value of the
        selector as a python integer, but sel is sampled dynamically.
      """
      sel = tf.random_uniform([], maxval=num_cases, dtype=tf.int32)
      # Pass the real x only to one of the func calls.
      return control_flow_ops.merge(
          [
              func(
                  control_flow_ops.switch(x, tf.equal(sel, case))[1],
                  case,
              )
              for case in range(num_cases)
          ]
      )[0]
  
file_path: tensor2tensor/tensor2tensor/data_generators/vqa_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  from tensorflow.python.ops import control_flow_ops
label_desc: Use image node_id 5 for calling a global function with example usage: _apply_with_random_selector(x, func, num_cases) and returns: control_flow_ops