import tensorflow as tf

    negative_idx = tf.logical_and(negative_idx, indicator)

    # Sample positive and negative samples separately
    if sample_size is None:
        max_num_pos = tf.reduce_sum(tf.cast(positive_idx, dtype=tf.int32))
    else:
        max_num_pos = int(positive_fraction * sample_size)
    sampled_pos_idx = subsample_indicator(positive_idx, max_num_pos)
