def _distributional_transform(self, x):
if tensorshape_util.rank(x.shape) is None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if isinstance(self._components_distribution, independent.Independent):<EOL><INDENT>univariate_components = self._components_distribution.distribution<EOL><DEDENT>else:<EOL><INDENT>univariate_components = self._components_distribution<EOL><DEDENT>with tf.control_dependencies([<EOL>assert_util.assert_equal(<EOL>univariate_components.is_scalar_event(),<EOL>True,<EOL>message="<STR_LIT>")<EOL>]):<EOL><INDENT>x_padded = self._pad_sample_dims(x)  <EOL>log_prob_x = univariate_components.log_prob(x_padded)  <EOL>cdf_x = univariate_components.cdf(x_padded)  <EOL>cumsum_log_prob_x = tf.reshape(<EOL>tf.math.cumsum(<EOL>tf.reshape(log_prob_x, [-<NUM_LIT:1>, self._event_size]),<EOL>exclusive=True,<EOL>axis=-<NUM_LIT:1>),<EOL>tf.shape(input=log_prob_x))  <EOL>logits_mix_prob = distribution_utils.pad_mixture_dimensions(<EOL>self.mixture_distribution.logits, self, self.mixture_distribution,<EOL>self._event_ndims)  <EOL>log_posterior_weights_x = logits_mix_prob + cumsum_log_prob_x<EOL>component_axis = tensorshape_util.rank(x.shape) - self._event_ndims<EOL>posterior_weights_x = tf.nn.softmax(log_posterior_weights_x,<EOL>axis=component_axis)<EOL>return tf.reduce_sum(<EOL>input_tensor=posterior_weights_x * cdf_x, axis=component_axis)<EOL><DEDENT>
Performs distributional transform of the mixture samples.

        Distributional transform removes the parameters from samples of a
        multivariate distribution by applying conditional CDFs:
          (F(x_1), F(x_2 | x1_), ..., F(x_d | x_1, ..., x_d-1))
        (the indexing is over the "flattened" event dimensions).
        The result is a sample of product of Uniform[0, 1] distributions.

        We assume that the components are factorized, so the conditional CDFs become
          F(x_i | x_1, ..., x_i-1) = sum_k w_i^k F_k (x_i),
        where w_i^k is the posterior mixture weight: for i > 0
          w_i^k = w_k prob_k(x_1, ..., x_i-1) / sum_k' w_k' prob_k'(x_1, ..., x_i-1)
        and w_0^k = w_k is the mixture probability of the k-th component.

        Arguments:
          x: Sample of mixture distribution

        Returns:
          Result of the distributional transform