code: def randn_sampler_switchover(shape, num_iters, use_gpu=False):
      # Benchmark by constructing samplers on the threshold of using the randn
      # rejection sampling and check that this threshold is set correctly by
      # benchmarking with bounds just above and below this threshold.
      # The uniform and randn samplers should have about the same performance
      # at this point.
  
      stddev_inside_bounds_before_using_randn = (
          _get_stddev_inside_bounds_before_using_randn(use_gpu)
      )
  
      epsilon = 0.001
  
      np.random.seed(1618)  # Make it reproducible.
  
      # 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:
          with ops.device("/cpu:0" if not use_gpu else "/gpu:0"):
              uniform_sampler_op = control_flow_ops.group(
                  random_ops.parameterized_truncated_normal(
                      shape,
                      means=0.0,
                      stddevs=1.0,
                      minvals=-stddev_inside_bounds_before_using_randn
                      + epsilon,
                      maxvals=0.01,
                  )
              )
              randn_sampler_op = control_flow_ops.group(
                  random_ops.parameterized_truncated_normal(
                      shape,
                      means=0.0,
                      stddevs=1.0,
                      minvals=-stddev_inside_bounds_before_using_randn
                      - epsilon,
                      maxvals=0.01,
                  )
              )
  
          # Burn-in to avoid session setup costs in the timing.
          sess.run(uniform_sampler_op)
          sess.run(uniform_sampler_op)
          uniform_dt = timeit.timeit(
              lambda: sess.run(uniform_sampler_op), number=num_iters
          )
  
          sess.run(randn_sampler_op)
          sess.run(randn_sampler_op)
          randn_dt = timeit.timeit(
              lambda: sess.run(randn_sampler_op), number=num_iters
          )
  
          return randn_dt, uniform_dt
  
imports: import functools
  import math
  import timeit
  import numpy
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.eager import backprop
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  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 random_ops
  from tensorflow.python.ops import stateless_random_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 5 for calling a global function with example usage: randn_sampler_switchover(shape, num_iters, use_gpu) and returns: randn_dt,  uniform_dt