# Path: disentanglement_lib/data/ground_truth/named_data.py
# def get_named_ground_truth_data(name):
# 
# Path: disentanglement_lib/visualize/visualize_util.py
# def save_image(image, image_path):
# def grid_save_images(images, image_path):
# def padded_grid(images, num_rows=None, padding_px=10, value=None):
# def padded_stack(images, padding_px=10, axis=0, value=None):
# def padding_array(image, padding_px, axis, value=None):
# def best_num_rows(num_elements, max_ratio=4):
# def pad_around(image, padding_px=10, axis=None, value=None):
# def add_below(image, padding_px=10, value=None):
# def save_animation(list_of_animated_images, image_path, fps):
# def cycle_factor(starting_index, num_indices, num_frames):
# def cycle_gaussian(starting_value, num_frames, loc=0., scale=1.):
# def cycle_interval(starting_value, num_frames, min_val, max_val):


import os
import numpy as np
from disentanglement_lib.data.ground_truth import named_data
from disentanglement_lib.visualize import visualize_util
from six.moves import range
from tensorflow.compat.v1 import gfile
  Args:
    dataset_name: String with name of dataset as defined in named_data.py.
    output_path: String with path in which to create the visualizations.
    num_animations: Integer with number of distinct animations to create.
    num_frames: Integer with number of frames in each animation.
    fps: Integer with frame rate for the animation.
  """
  data = named_data.get_named_ground_truth_data(dataset_name)
  random_state = np.random.RandomState(0)

  # Create output folder if necessary.
  path = os.path.join(output_path, dataset_name)
  if not gfile.IsDirectory(path):
    gfile.MakeDirs(path)

  # Create still images.
  for i in range(data.num_factors):
    factors = data.sample_factors(16, random_state)
    indices = [j for j in range(data.num_factors) if i != j]
    factors[:, indices] = factors[0, indices]
    images = data.sample_observations_from_factors(factors, random_state)
    visualize_util.grid_save_images(
        images, os.path.join(path, "variations_of_factor%s.png" % i))

  # Create animations.
  for i in range(num_animations):
    base_factor = data.sample_factors(1, random_state)
    images = []
    for j, num_atoms in enumerate(data.factors_num_values):
      factors = np.repeat(base_factor, num_frames, axis=0)

# Path: disentanglement_lib/data/ground_truth/named_data.py
# def get_named_ground_truth_data(name):
# 
# Path: disentanglement_lib/visualize/visualize_util.py
# def save_image(image, image_path):
# def grid_save_images(images, image_path):
# def padded_grid(images, num_rows=None, padding_px=10, value=None):
# def padded_stack(images, padding_px=10, axis=0, value=None):
# def padding_array(image, padding_px, axis, value=None):
# def best_num_rows(num_elements, max_ratio=4):
# def pad_around(image, padding_px=10, axis=None, value=None):
# def add_below(image, padding_px=10, value=None):
# def save_animation(list_of_animated_images, image_path, fps):
# def cycle_factor(starting_index, num_indices, num_frames):
# def cycle_gaussian(starting_value, num_frames, loc=0., scale=1.):
# def cycle_interval(starting_value, num_frames, min_val, max_val):


# Path: disentanglement_lib/visualize/visualize_dataset.py
import os
import numpy as np
from disentanglement_lib.data.ground_truth import named_data
from disentanglement_lib.visualize import visualize_util
from six.moves import range
from tensorflow.compat.v1 import gfile

  Args:
    dataset_name: String with name of dataset as defined in named_data.py.
    output_path: String with path in which to create the visualizations.
    num_animations: Integer with number of distinct animations to create.
    num_frames: Integer with number of frames in each animation.
    fps: Integer with frame rate for the animation.
  """
  data = named_data.get_named_ground_truth_data(dataset_name)
  random_state = np.random.RandomState(0)

  # Create output folder if necessary.
  path = os.path.join(output_path, dataset_name)
  if not gfile.IsDirectory(path):
    gfile.MakeDirs(path)

  # Create still images.
  for i in range(data.num_factors):
    factors = data.sample_factors(16, random_state)
    indices = [j for j in range(data.num_factors) if i != j]
    factors[:, indices] = factors[0, indices]
    images = data.sample_observations_from_factors(factors, random_state)
    visualize_util.grid_save_images(
        images, os.path.join(path, "variations_of_factor%s.png" % i))

  # Create animations.
  for i in range(num_animations):
    base_factor = data.sample_factors(1, random_state)
    images = []
    for j, num_atoms in enumerate(data.factors_num_values):
      factors = np.repeat(base_factor, num_frames, axis=0)

      factors[:, j] = visualize_util.cycle_factor(base_factor[0, j], num_atoms,