import tensorflow as tf


    Returns:

    A boolean tensor of shape [M, N], True for entries which are sampled.
    """

    def _minibatch_subsample_fn(inputs):
        indicators, targets = inputs
        return sample_balanced_positive_negative(tf.cast(indicators, tf.bool),
                                                 sample_size,
                                                 tf.cast(targets, tf.bool),
                                                 positive_fraction=positive_fraction)

    return tf.cast(tf.map_fn(_minibatch_subsample_fn, [indicators, labels],
                             dtype=tf.bool,
                             parallel_iterations=16,
                             back_prop=True),
                   dtype=dtype)
