import tensorflow as tf

                   [inputs_shape[0], inputs_shape[1], inputs_shape[2], 1, nr_mix]), m2, m3
    ],
                      axis=3)
    centered_inputs = inputs - means
    inv_stdv = tf.exp(-log_scales)
    plus_in = inv_stdv * (centered_inputs + 1. / 255.)
    cdf_plus = tf.nn.sigmoid(plus_in)
    min_in = inv_stdv * (centered_inputs - 1. / 255.)
    cdf_min = tf.nn.sigmoid(min_in)
    log_cdf_plus = plus_in - tf.nn.softplus(plus_in)
    log_one_minus_cdf_min = -tf.nn.softplus(min_in)
    cdf_delta = cdf_plus - cdf_min
    mid_in = inv_stdv * centered_inputs
    log_pdf_mid = mid_in - log_scales - 2. * tf.nn.softplus(mid_in)
    log_probs = tf.select(
        inputs < -0.999, log_cdf_plus,
        tf.select(
            inputs > 0.999, log_one_minus_cdf_min,
            tf.select(cdf_delta > 1e-5, tf.log(tf.maximum(cdf_delta, 1e-12)),
                      log_pdf_mid - np.log(127.5))))
