import tensorflow as tf

        with tf.control_dependencies([p]):
            return tf.reduce_mean(loss)

    loss = tf.map_fn(fn=lambda inp: sample_compute(inp), elems=tf.range(resample), dtype=tf.float32,
                     parallel_iterations=32)
    final_loss = tf.reduce_mean(loss)

    return final_loss


