# 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 scipy.io as sio
from disentanglement_lib.data.ground_truth import ground_truth_data
from disentanglement_lib.data.ground_truth import util
from six.moves import range
from sklearn.utils import extmath
from tensorflow.compat.v1 import gfile
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


CARS3D_PATH = os.path.join(
    os.environ.get("DISENTANGLEMENT_LIB_DATA", "."), "cars")



class Cars3D(ground_truth_data.GroundTruthData):
  """Cars3D data set.

  The data set was first used in the paper "Deep Visual Analogy-Making"
  (https://papers.nips.cc/paper/5845-deep-visual-analogy-making) and can be
  downloaded from http://www.scottreed.info/. The images are rescaled to 64x64.

  The ground-truth factors of variation are:
  0 - elevation (4 different values)
  1 - azimuth (24 different values)
  2 - object type (183 different values)
  """

  def __init__(self):
    self.factor_sizes = [4, 24, 183]
    features = extmath.cartesian(
        [np.array(list(range(i))) for i in self.factor_sizes])
    self.latent_factor_indices = [0, 1, 2]
    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/cars3d.py
import os
import numpy as np
import PIL
import scipy.io as sio
from disentanglement_lib.data.ground_truth import ground_truth_data
from disentanglement_lib.data.ground_truth import util
from six.moves import range
from sklearn.utils import extmath
from tensorflow.compat.v1 import gfile

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


CARS3D_PATH = os.path.join(
    os.environ.get("DISENTANGLEMENT_LIB_DATA", "."), "cars")



class Cars3D(ground_truth_data.GroundTruthData):
  """Cars3D data set.

  The data set was first used in the paper "Deep Visual Analogy-Making"
  (https://papers.nips.cc/paper/5845-deep-visual-analogy-making) and can be
  downloaded from http://www.scottreed.info/. The images are rescaled to 64x64.

  The ground-truth factors of variation are:
  0 - elevation (4 different values)
  1 - azimuth (24 different values)
  2 - object type (183 different values)
  """

  def __init__(self):
    self.factor_sizes = [4, 24, 183]
    features = extmath.cartesian(
        [np.array(list(range(i))) for i in self.factor_sizes])
    self.latent_factor_indices = [0, 1, 2]
    self.num_total_factors = features.shape[1]
    self.index = util.StateSpaceAtomIndex(self.factor_sizes, features)

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