# Path: disentanglement_lib/data/ground_truth/named_data.py
# def get_named_ground_truth_data(name):
# 
# Path: disentanglement_lib/evaluation/udr/metrics/udr.py
# def relative_strength_disentanglement(corr_matrix):
# def spearman_correlation_conv(vec1, vec2):
# def lasso_correlation_matrix(vec1, vec2, random_state=None):
# def _generate_representation_batch(ground_truth_data, representation_functions,
#                                    batch_size, random_state):
# def _generate_representation_dataset(ground_truth_data,
#                                      representation_functions, batch_size,
#                                      num_data_points, random_state):
# def compute_udr_sklearn(ground_truth_data,
#                         representation_functions,
#                         random_state,
#                         batch_size,
#                         num_data_points,
#                         correlation_matrix="lasso",
#                         filter_low_kl=True,
#                         include_raw_correlations=True,
#                         kl_filter_threshold=0.01):
# 
# Path: disentanglement_lib/utils/results.py
# def update_result_directory(result_directory,
#                             step_name,
#                             results_dict,
#                             old_result_directory=None):
# def _copy_recursively(path_to_old_dir, path_to_new_dir):
# def copydir(path_to_old_dir, path_to_new_dir):
# def save_gin(config_path):
#   def default(self, obj):
# def save_dict(config_path, dict_with_info):
# def gin_dict(config_path=None):
# def namespaced_dict(base_dict=None, **named_dicts):
# def aggregate_json_results(base_path):
# class Encoder(json.JSONEncoder):


import contextlib
import os
import time
import numpy as np
import tensorflow.compat.v1 as tf
import tensorflow_hub as hub
import gin.tf
from absl import flags
from disentanglement_lib.data.ground_truth import named_data
from disentanglement_lib.evaluation.udr.metrics import udr  # pylint: disable=unused-import
from disentanglement_lib.utils import results
(https://arxiv.org/abs/1905.12614)
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function



FLAGS = flags.FLAGS


@gin.configurable("evaluation", blacklist=["model_dirs", "output_dir"])
def evaluate(model_dirs,
             output_dir,
             evaluation_fn=gin.REQUIRED,
             random_seed=gin.REQUIRED,
             name=""):
  """Loads a trained estimator and evaluates it according to beta-VAE metric."""
  # The name will be part of the gin config and can be used to tag results.
  del name

  # Set up time to keep track of elapsed time in results.
  experiment_timer = time.time()

  # Automatically set the proper dataset if necessary. We replace the active
  # gin config as this will lead to a valid gin config file where the dataset
  # is present.
  if gin.query_parameter("dataset.name") == "auto":
    # Obtain the dataset name from the gin config of the previous step.
    gin_config_file = os.path.join(model_dirs[0], "results", "gin", "train.gin")

# Path: disentanglement_lib/data/ground_truth/named_data.py
# def get_named_ground_truth_data(name):
# 
# Path: disentanglement_lib/evaluation/udr/metrics/udr.py
# def relative_strength_disentanglement(corr_matrix):
# def spearman_correlation_conv(vec1, vec2):
# def lasso_correlation_matrix(vec1, vec2, random_state=None):
# def _generate_representation_batch(ground_truth_data, representation_functions,
#                                    batch_size, random_state):
# def _generate_representation_dataset(ground_truth_data,
#                                      representation_functions, batch_size,
#                                      num_data_points, random_state):
# def compute_udr_sklearn(ground_truth_data,
#                         representation_functions,
#                         random_state,
#                         batch_size,
#                         num_data_points,
#                         correlation_matrix="lasso",
#                         filter_low_kl=True,
#                         include_raw_correlations=True,
#                         kl_filter_threshold=0.01):
# 
# Path: disentanglement_lib/utils/results.py
# def update_result_directory(result_directory,
#                             step_name,
#                             results_dict,
#                             old_result_directory=None):
# def _copy_recursively(path_to_old_dir, path_to_new_dir):
# def copydir(path_to_old_dir, path_to_new_dir):
# def save_gin(config_path):
#   def default(self, obj):
# def save_dict(config_path, dict_with_info):
# def gin_dict(config_path=None):
# def namespaced_dict(base_dict=None, **named_dicts):
# def aggregate_json_results(base_path):
# class Encoder(json.JSONEncoder):


# Path: disentanglement_lib/evaluation/udr/evaluate.py
import contextlib
import os
import time
import numpy as np
import tensorflow.compat.v1 as tf
import tensorflow_hub as hub
import gin.tf
from absl import flags
from disentanglement_lib.data.ground_truth import named_data
from disentanglement_lib.evaluation.udr.metrics import udr  # pylint: disable=unused-import
from disentanglement_lib.utils import results

(https://arxiv.org/abs/1905.12614)
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function



FLAGS = flags.FLAGS


@gin.configurable("evaluation", blacklist=["model_dirs", "output_dir"])
def evaluate(model_dirs,
             output_dir,
             evaluation_fn=gin.REQUIRED,
             random_seed=gin.REQUIRED,
             name=""):
  """Loads a trained estimator and evaluates it according to beta-VAE metric."""
  # The name will be part of the gin config and can be used to tag results.
  del name

  # Set up time to keep track of elapsed time in results.
  experiment_timer = time.time()

  # Automatically set the proper dataset if necessary. We replace the active
  # gin config as this will lead to a valid gin config file where the dataset
  # is present.
  if gin.query_parameter("dataset.name") == "auto":
    # Obtain the dataset name from the gin config of the previous step.
    gin_config_file = os.path.join(model_dirs[0], "results", "gin", "train.gin")

    gin_dict = results.gin_dict(gin_config_file)