def _init_sampler(tc, init, num):
  """Returns a func to generate a random tensor of shape [num].

  Args:
    tc: An instance of TensorFlowTestCase.
    init: An Initializer that generates a tensor of a given shape
    num: Size of 1D tensor to create.

  Returns:
    Function to generate a random tensor.
  """

  def func():
    with tc.test_session():
      return init([num]).eval()

  return func