# Path: disentanglement_lib/methods/semi_supervised/semi_supervised_vae.py
# class BaseS2VAE(vae.BaseVAE):
# class S2BetaVAE(BaseS2VAE):
# class SupervisedVAE(BaseS2VAE):
# class MineVAE(BaseS2VAE):
# class S2FactorVAE(BaseS2VAE):
# class S2DIPVAE(BaseS2VAE):
# class S2BetaTCVAE(BaseS2VAE):
#   def __init__(self, factor_sizes):
#   def model_fn(self, features, labels, mode, params):
# def sample_from_latent_distribution(z_mean, z_logvar):
# def compute_gaussian_kl(z_mean, z_logvar):
# def make_metric_fn(*names):
#   def metric_fn(*args):
# def make_annealer(gamma,
#                   step,
#                   iteration_threshold=gin.REQUIRED,
#                   anneal_fn=gin.REQUIRED):
# def fixed_annealer(gamma, step, iteration_threshold):
# def annealed_annealer(gamma, step, iteration_threshold):
# def fine_tune_annealer(gamma, step, iteration_threshold):
# def make_supervised_loss(representation, labels,
#                          factor_sizes=None, loss_fn=gin.REQUIRED):
# def normalize_labels(labels, factors_num_values):
# def supervised_regularizer_l2(representation, labels,
#                               factor_sizes=None,
#                               learn_scale=True):
# def supervised_regularizer_xent(representation, labels,
#                                 factor_sizes=None):
# def supervised_regularizer_cov(representation, labels,
#                                factor_sizes=None):
# def supervised_regularizer_embed(representation, labels,
#                                  factor_sizes, sigma=gin.REQUIRED,
#                                  use_order=False):
#   def __init__(self, factor_sizes, beta=gin.REQUIRED, gamma_sup=gin.REQUIRED):
#   def unsupervised_regularizer(self, kl_loss, z_mean, z_logvar, z_sampled):
#   def model_fn(self, features, labels, mode, params):
# def mine(x, z, name_net="estimator_network"):
#   def __init__(self, factor_sizes, gamma_sup=gin.REQUIRED, beta=gin.REQUIRED):
#   def model_fn(self, features, labels, mode, params):
#   def __init__(self, factor_sizes, gamma=gin.REQUIRED, gamma_sup=gin.REQUIRED):
#   def model_fn(self, features, labels, mode, params):
#   def __init__(self,
#                factor_sizes,
#                lambda_od=gin.REQUIRED,
#                lambda_d_factor=gin.REQUIRED,
#                gamma_sup=gin.REQUIRED,
#                dip_type="i"):
#   def unsupervised_regularizer(self, kl_loss, z_mean, z_logvar, z_sampled):
#   def __init__(self, factor_sizes, beta=gin.REQUIRED, gamma_sup=gin.REQUIRED):
#   def unsupervised_regularizer(self, kl_loss, z_mean, z_logvar, z_sampled):


from absl.testing import parameterized
from disentanglement_lib.methods.semi_supervised import semi_supervised_vae  # pylint: disable=unused-import
import numpy as np
import tensorflow.compat.v1 as tf
# 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 the semi supervised training protocol."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function



class S2VaeTest(parameterized.TestCase, tf.test.TestCase):

  @parameterized.parameters((0, 100., 100.01), (10, 100., 100.01),
                            (100, 100., 100.01), (101, 100., 100.01))
  def test_fixed_annealer(self, step, target_low, target_high):
    c_max = 100.
    iteration_threshold = 100
    test_value = semi_supervised_vae.fixed_annealer(c_max, step,
                                                    iteration_threshold)
    self.assertBetween(test_value, target_low, target_high)

  @parameterized.parameters((0, 0., 0.01), (10, 10., 10.01),
                            (100, 100., 100.01), (101, 100., 100.01))
  def test_anneal_annealer(self, step, target_low, target_high):
    c_max = 100.
    iteration_threshold = 100
    with self.test_session() as sess:
      test_value = sess.run(

# Path: disentanglement_lib/methods/semi_supervised/semi_supervised_vae.py
# class BaseS2VAE(vae.BaseVAE):
# class S2BetaVAE(BaseS2VAE):
# class SupervisedVAE(BaseS2VAE):
# class MineVAE(BaseS2VAE):
# class S2FactorVAE(BaseS2VAE):
# class S2DIPVAE(BaseS2VAE):
# class S2BetaTCVAE(BaseS2VAE):
#   def __init__(self, factor_sizes):
#   def model_fn(self, features, labels, mode, params):
# def sample_from_latent_distribution(z_mean, z_logvar):
# def compute_gaussian_kl(z_mean, z_logvar):
# def make_metric_fn(*names):
#   def metric_fn(*args):
# def make_annealer(gamma,
#                   step,
#                   iteration_threshold=gin.REQUIRED,
#                   anneal_fn=gin.REQUIRED):
# def fixed_annealer(gamma, step, iteration_threshold):
# def annealed_annealer(gamma, step, iteration_threshold):
# def fine_tune_annealer(gamma, step, iteration_threshold):
# def make_supervised_loss(representation, labels,
#                          factor_sizes=None, loss_fn=gin.REQUIRED):
# def normalize_labels(labels, factors_num_values):
# def supervised_regularizer_l2(representation, labels,
#                               factor_sizes=None,
#                               learn_scale=True):
# def supervised_regularizer_xent(representation, labels,
#                                 factor_sizes=None):
# def supervised_regularizer_cov(representation, labels,
#                                factor_sizes=None):
# def supervised_regularizer_embed(representation, labels,
#                                  factor_sizes, sigma=gin.REQUIRED,
#                                  use_order=False):
#   def __init__(self, factor_sizes, beta=gin.REQUIRED, gamma_sup=gin.REQUIRED):
#   def unsupervised_regularizer(self, kl_loss, z_mean, z_logvar, z_sampled):
#   def model_fn(self, features, labels, mode, params):
# def mine(x, z, name_net="estimator_network"):
#   def __init__(self, factor_sizes, gamma_sup=gin.REQUIRED, beta=gin.REQUIRED):
#   def model_fn(self, features, labels, mode, params):
#   def __init__(self, factor_sizes, gamma=gin.REQUIRED, gamma_sup=gin.REQUIRED):
#   def model_fn(self, features, labels, mode, params):
#   def __init__(self,
#                factor_sizes,
#                lambda_od=gin.REQUIRED,
#                lambda_d_factor=gin.REQUIRED,
#                gamma_sup=gin.REQUIRED,
#                dip_type="i"):
#   def unsupervised_regularizer(self, kl_loss, z_mean, z_logvar, z_sampled):
#   def __init__(self, factor_sizes, beta=gin.REQUIRED, gamma_sup=gin.REQUIRED):
#   def unsupervised_regularizer(self, kl_loss, z_mean, z_logvar, z_sampled):


# Path: disentanglement_lib/methods/semi_supervised/semi_supervised_vae_test.py
from absl.testing import parameterized
from disentanglement_lib.methods.semi_supervised import semi_supervised_vae  # pylint: disable=unused-import
import numpy as np
import tensorflow.compat.v1 as tf

# 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 the semi supervised training protocol."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function



class S2VaeTest(parameterized.TestCase, tf.test.TestCase):

  @parameterized.parameters((0, 100., 100.01), (10, 100., 100.01),
                            (100, 100., 100.01), (101, 100., 100.01))
  def test_fixed_annealer(self, step, target_low, target_high):
    c_max = 100.
    iteration_threshold = 100
    test_value = semi_supervised_vae.fixed_annealer(c_max, step,
                                                    iteration_threshold)
    self.assertBetween(test_value, target_low, target_high)

  @parameterized.parameters((0, 0., 0.01), (10, 10., 10.01),
                            (100, 100., 100.01), (101, 100., 100.01))
  def test_anneal_annealer(self, step, target_low, target_high):
    c_max = 100.
    iteration_threshold = 100
    with self.test_session() as sess:
      test_value = sess.run(

          semi_supervised_vae.annealed_annealer(c_max, step,