# Path: enn/losses/vi_losses.py
# def get_awgn_loglike_fn(sigma_w: float
#                         ) -> Callable[[base.Output, base.Batch], float]:
#   def log_likelihood_fn(out: base.Output, batch: base.Batch):
# def get_categorical_loglike_fn(num_classes: int
#                                ) -> Callable[[base.Output, base.Batch], float]:
#   def log_likelihood_fn(out: base.Output, batch: base.Batch):
# def log_normal_prob(x: float, mu: float = 0, sigma: float = 1):
# def sum_log_scale_mixture_normal(x: base.Array,
#                                  sigma_1: float,
#                                  sigma_2: float,
#                                  mu_1: float = 0.,
#                                  mu_2: float = 0.,
#                                  pi: float = 1.,) -> float:
# def normal_log_prob(latent: base.Array, sigma: float = 1, mu: float = 0):
# def get_sample_based_model_prior_kl_fn(
#     num_samples: float, sigma_1: float, sigma_2: float = 1., scale: float = 1.
# ) -> Callable[[base.Output, hk.Params, base.Index], float]:
#   def model_prior_kl_fn(out: base.Output, params: hk.Params,
#                         index: base.Index) -> float:
# def get_analytical_diagonal_linear_model_prior_kl_fn(
#     num_samples: float, sigma_0: float
# ) -> Callable[[base.Output, hk.Params, base.Index], float]:
#   def model_prior_kl_fn(
#       out: base.Output,
#       params: hk.Params,
#       index: base.Index) -> float:
# def get_analytical_linear_model_prior_kl_fn(
#     num_samples: float, sigma_0: float
# ) -> Callable[[base.Output, hk.Params, base.Index], float]:
#   def model_prior_kl_fn(
#       out: base.Output,
#       params: hk.Params,
#       index: base.Index) -> float:
# def get_analytical_hyperflow_model_prior_kl_fn(
#     num_samples: float, sigma_0: float
# ) -> Callable[[base.Output, hk.Params, base.Index], float]:
#   def model_prior_kl_fn(out, params, index):


from absl.testing import absltest
from absl.testing import parameterized
from enn.losses import vi_losses
import numpy as np
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Tests for ENN vi losses."""



class LossesTest(parameterized.TestCase):

  @parameterized.parameters([
      [1., 0., 1.0],
      [1., 0., 10.0],
      [10., 1., 1.0],
      [10., 1., 10.0],
      [10., 10., 1.0],
  ])
  def test_analytical_diagonal_linear_model_prior_kl_fn(
      self, sigma: float, mu: float, sigma_0: float):
    """Tests the elbo function for the case of simple weights and biases."""

    num_params = 10

# Path: enn/losses/vi_losses.py
# def get_awgn_loglike_fn(sigma_w: float
#                         ) -> Callable[[base.Output, base.Batch], float]:
#   def log_likelihood_fn(out: base.Output, batch: base.Batch):
# def get_categorical_loglike_fn(num_classes: int
#                                ) -> Callable[[base.Output, base.Batch], float]:
#   def log_likelihood_fn(out: base.Output, batch: base.Batch):
# def log_normal_prob(x: float, mu: float = 0, sigma: float = 1):
# def sum_log_scale_mixture_normal(x: base.Array,
#                                  sigma_1: float,
#                                  sigma_2: float,
#                                  mu_1: float = 0.,
#                                  mu_2: float = 0.,
#                                  pi: float = 1.,) -> float:
# def normal_log_prob(latent: base.Array, sigma: float = 1, mu: float = 0):
# def get_sample_based_model_prior_kl_fn(
#     num_samples: float, sigma_1: float, sigma_2: float = 1., scale: float = 1.
# ) -> Callable[[base.Output, hk.Params, base.Index], float]:
#   def model_prior_kl_fn(out: base.Output, params: hk.Params,
#                         index: base.Index) -> float:
# def get_analytical_diagonal_linear_model_prior_kl_fn(
#     num_samples: float, sigma_0: float
# ) -> Callable[[base.Output, hk.Params, base.Index], float]:
#   def model_prior_kl_fn(
#       out: base.Output,
#       params: hk.Params,
#       index: base.Index) -> float:
# def get_analytical_linear_model_prior_kl_fn(
#     num_samples: float, sigma_0: float
# ) -> Callable[[base.Output, hk.Params, base.Index], float]:
#   def model_prior_kl_fn(
#       out: base.Output,
#       params: hk.Params,
#       index: base.Index) -> float:
# def get_analytical_hyperflow_model_prior_kl_fn(
#     num_samples: float, sigma_0: float
# ) -> Callable[[base.Output, hk.Params, base.Index], float]:
#   def model_prior_kl_fn(out, params, index):


# Path: enn/losses/vi_losses_test.py
from absl.testing import absltest
from absl.testing import parameterized
from enn.losses import vi_losses
import numpy as np

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Tests for ENN vi losses."""



class LossesTest(parameterized.TestCase):

  @parameterized.parameters([
      [1., 0., 1.0],
      [1., 0., 10.0],
      [10., 1., 1.0],
      [10., 1., 10.0],
      [10., 10., 1.0],
  ])
  def test_analytical_diagonal_linear_model_prior_kl_fn(
      self, sigma: float, mu: float, sigma_0: float):
    """Tests the elbo function for the case of simple weights and biases."""

    num_params = 10

    kl_fn = vi_losses.get_analytical_diagonal_linear_model_prior_kl_fn(