# Path: disentanglement_lib/data/ground_truth/ground_truth_data.py
# class GroundTruthData(object):
#   def num_factors(self):
#   def factors_num_values(self):
#   def observation_shape(self):
#   def sample_factors(self, num, random_state):
#   def sample_observations_from_factors(self, factors, random_state):
#   def sample(self, num, random_state):
#   def sample_observations(self, num, random_state):
# 
# Path: disentanglement_lib/data/ground_truth/util.py
# def tf_data_set_from_ground_truth_data(ground_truth_data, random_seed):
#   def generator():
#   def __init__(self, factor_sizes, latent_factor_indices):
#   def num_latent_factors(self):
#   def sample_latent_factors(self, num, random_state):
#   def sample_all_factors(self, latent_factors, random_state):
#   def _sample_factor(self, i, num, random_state):
#   def __init__(self, factor_sizes, features):
#   def features_to_index(self, features):
#   def _features_to_state_space_index(self, features):
# class SplitDiscreteStateSpace(object):
# class StateSpaceAtomIndex(object):


import os
import numpy as np
import PIL
import tensorflow.compat.v1 as tf
from disentanglement_lib.data.ground_truth import ground_truth_data
from disentanglement_lib.data.ground_truth import util
from six.moves import range
from six.moves import zip

SMALLNORB_CHUNKS = [
    "5x46789x9x18x6x2x96x96-training",
    "5x01235x9x18x6x2x96x96-testing",
]


class SmallNORB(ground_truth_data.GroundTruthData):
  """SmallNORB dataset.

  The data set can be downloaded from
  https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/. Images are resized to 64x64.

  The ground-truth factors of variation are:
  0 - category (5 different values)
  1 - elevation (9 different values)
  2 - azimuth (18 different values)
  3 - lighting condition (6 different values)

  The instance in each category is randomly sampled when generating the images.
  """

  def __init__(self):
    self.images, features = _load_small_norb_chunks(SMALLNORB_TEMPLATE,
                                                    SMALLNORB_CHUNKS)
    self.factor_sizes = [5, 10, 9, 18, 6]
    # Instances are not part of the latent space.
    self.latent_factor_indices = [0, 2, 3, 4]
    self.num_total_factors = features.shape[1]
    self.index = util.StateSpaceAtomIndex(self.factor_sizes, features)

# Path: disentanglement_lib/data/ground_truth/ground_truth_data.py
# class GroundTruthData(object):
#   def num_factors(self):
#   def factors_num_values(self):
#   def observation_shape(self):
#   def sample_factors(self, num, random_state):
#   def sample_observations_from_factors(self, factors, random_state):
#   def sample(self, num, random_state):
#   def sample_observations(self, num, random_state):
# 
# Path: disentanglement_lib/data/ground_truth/util.py
# def tf_data_set_from_ground_truth_data(ground_truth_data, random_seed):
#   def generator():
#   def __init__(self, factor_sizes, latent_factor_indices):
#   def num_latent_factors(self):
#   def sample_latent_factors(self, num, random_state):
#   def sample_all_factors(self, latent_factors, random_state):
#   def _sample_factor(self, i, num, random_state):
#   def __init__(self, factor_sizes, features):
#   def features_to_index(self, features):
#   def _features_to_state_space_index(self, features):
# class SplitDiscreteStateSpace(object):
# class StateSpaceAtomIndex(object):


# Path: disentanglement_lib/data/ground_truth/norb.py
import os
import numpy as np
import PIL
import tensorflow.compat.v1 as tf
from disentanglement_lib.data.ground_truth import ground_truth_data
from disentanglement_lib.data.ground_truth import util
from six.moves import range
from six.moves import zip


SMALLNORB_CHUNKS = [
    "5x46789x9x18x6x2x96x96-training",
    "5x01235x9x18x6x2x96x96-testing",
]


class SmallNORB(ground_truth_data.GroundTruthData):
  """SmallNORB dataset.

  The data set can be downloaded from
  https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/. Images are resized to 64x64.

  The ground-truth factors of variation are:
  0 - category (5 different values)
  1 - elevation (9 different values)
  2 - azimuth (18 different values)
  3 - lighting condition (6 different values)

  The instance in each category is randomly sampled when generating the images.
  """

  def __init__(self):
    self.images, features = _load_small_norb_chunks(SMALLNORB_TEMPLATE,
                                                    SMALLNORB_CHUNKS)
    self.factor_sizes = [5, 10, 9, 18, 6]
    # Instances are not part of the latent space.
    self.latent_factor_indices = [0, 2, 3, 4]
    self.num_total_factors = features.shape[1]
    self.index = util.StateSpaceAtomIndex(self.factor_sizes, features)

    self.state_space = util.SplitDiscreteStateSpace(self.factor_sizes,