code: def scheduled_sample_prob(ground_truth_x,
                            generated_x,
                            batch_size,
                            scheduled_sample_var):
    
    probability_threshold = scheduled_sample_var
    probability_of_generated = tf.random_uniform([batch_size])
    return tf.where(probability_of_generated > probability_threshold,
                    generated_x, ground_truth_x)
docs: Probability based scheduled sampling.
  
    Args:
      ground_truth_x: tensor of ground-truth data points.
      generated_x: tensor of generated data points.
      batch_size: batch size
      scheduled_sample_var: probability of choosing from ground_truth.
    Returns:
      New batch with randomly selected data points.