# Path: meta_dataset/learners/experimental/base.py
# class NotBuiltError(RuntimeError):
# class ExperimentalLearner(learner_base.Learner):
# class ExperimentalEpisodicLearner(ExperimentalLearner,
#                                   learner_base.EpisodicLearner):
# class ExperimentalBatchLearner(ExperimentalLearner, learner_base.BatchLearner):
#   def __init__(self):
# def class_specific_data(onehot_labels, data, num_classes, axis=0):
#   def __init__(self, **kwargs):
#   def compute_regularizer(self, onehot_labels, predictions):
#   def build(self):
#   def variables(self):
#   def trainable_variables(self):
# 
# Path: meta_dataset/models/experimental/reparameterizable_base.py
# def is_variable(obj):
# def is_trainable_variable(obj):
# def is_batch_norm_module(obj):
# def corner_case_setattr(target, attr, value):
# def corner_case_getattr(target, attr):
# def chained_getattr(obj, path):
# def _patch_getattribute(cls, new_getattribute):
# def _custom_getter(getter, classes=(tf.Module,)):
#     def new_getattribute(obj, name, orig_getattribute=orig_getattribute):
#   def reparameterize(self, replacements):
#     def getter(v_source):
#   def reparameterizables(self,
#                          variable_predicate=is_variable,
#                          module_predicate=None,
#                          with_path=False):
#       def path_prefixes(path):
#       def satisfies_module_predicate(variable_with_path):
# class ReparameterizableModule(tf.Module):


import itertools
import math
import gin.tf
import tensorflow as tf
import tensorflow_probability as tfp
from meta_dataset.learners.experimental import base as learner_base
from meta_dataset.models.experimental import reparameterizable_base
                                    sample_covariance)
    weighted_covariance /= tf.reduce_sum(
        input_tensor=responsibilities, axis=0)[:, tf.newaxis, tf.newaxis]

    return (
        _split_and_squeeze(sample_mean, num_splits=num_classes),
        _split_and_squeeze(weighted_covariance, num_splits=num_classes),
        [mixing_logits],
    )
  else:
    avg_x_squared = (
        tf.matmul(responsibilities, embeddings**2, transpose_a=True) /
        tf.reduce_sum(input_tensor=responsibilities, axis=0)[:, tf.newaxis])
    avg_means_squared = sample_mean**2
    avg_x_means = (
        sample_mean *
        tf.matmul(responsibilities, embeddings, transpose_a=True) /
        tf.reduce_sum(input_tensor=responsibilities, axis=0)[:, tf.newaxis])
    sample_variances = (
        avg_x_squared - 2 * avg_x_means + avg_means_squared +
        damping * tf.ones(dim))
    log_variances = tf.math.log(sample_variances)
    return (
        _split_and_squeeze(sample_mean, num_splits=num_classes),
        _split_and_squeeze(log_variances, num_splits=num_classes),
        [mixing_logits],
    )


class ReparameterizableClassMixture(

# Path: meta_dataset/learners/experimental/base.py
# class NotBuiltError(RuntimeError):
# class ExperimentalLearner(learner_base.Learner):
# class ExperimentalEpisodicLearner(ExperimentalLearner,
#                                   learner_base.EpisodicLearner):
# class ExperimentalBatchLearner(ExperimentalLearner, learner_base.BatchLearner):
#   def __init__(self):
# def class_specific_data(onehot_labels, data, num_classes, axis=0):
#   def __init__(self, **kwargs):
#   def compute_regularizer(self, onehot_labels, predictions):
#   def build(self):
#   def variables(self):
#   def trainable_variables(self):
# 
# Path: meta_dataset/models/experimental/reparameterizable_base.py
# def is_variable(obj):
# def is_trainable_variable(obj):
# def is_batch_norm_module(obj):
# def corner_case_setattr(target, attr, value):
# def corner_case_getattr(target, attr):
# def chained_getattr(obj, path):
# def _patch_getattribute(cls, new_getattribute):
# def _custom_getter(getter, classes=(tf.Module,)):
#     def new_getattribute(obj, name, orig_getattribute=orig_getattribute):
#   def reparameterize(self, replacements):
#     def getter(v_source):
#   def reparameterizables(self,
#                          variable_predicate=is_variable,
#                          module_predicate=None,
#                          with_path=False):
#       def path_prefixes(path):
#       def satisfies_module_predicate(variable_with_path):
# class ReparameterizableModule(tf.Module):


# Path: meta_dataset/models/experimental/reparameterizable_distributions.py
import itertools
import math
import gin.tf
import tensorflow as tf
import tensorflow_probability as tfp
from meta_dataset.learners.experimental import base as learner_base
from meta_dataset.models.experimental import reparameterizable_base

                                    sample_covariance)
    weighted_covariance /= tf.reduce_sum(
        input_tensor=responsibilities, axis=0)[:, tf.newaxis, tf.newaxis]

    return (
        _split_and_squeeze(sample_mean, num_splits=num_classes),
        _split_and_squeeze(weighted_covariance, num_splits=num_classes),
        [mixing_logits],
    )
  else:
    avg_x_squared = (
        tf.matmul(responsibilities, embeddings**2, transpose_a=True) /
        tf.reduce_sum(input_tensor=responsibilities, axis=0)[:, tf.newaxis])
    avg_means_squared = sample_mean**2
    avg_x_means = (
        sample_mean *
        tf.matmul(responsibilities, embeddings, transpose_a=True) /
        tf.reduce_sum(input_tensor=responsibilities, axis=0)[:, tf.newaxis])
    sample_variances = (
        avg_x_squared - 2 * avg_x_means + avg_means_squared +
        damping * tf.ones(dim))
    log_variances = tf.math.log(sample_variances)
    return (
        _split_and_squeeze(sample_mean, num_splits=num_classes),
        _split_and_squeeze(log_variances, num_splits=num_classes),
        [mixing_logits],
    )


class ReparameterizableClassMixture(

    reparameterizable_base.ReparameterizableModule):