# Path: ldif/util/net_util.py
# def twin_inference(inference_fun, observation, element_count,
#                    flat_element_length, model_config):
# def get_normalizer_and_mode(model_config):
# def conv_layer(inputs, depth, model_config):
# def maxpool2x2_layer(inputs):
# def down_layer(inputs, depth, model_config):
# def up_layer(inputs, spatial_dims, depth, model_config):
# def encode(inputs,
#            model_config,
#            conv_layer_depths,
#            fc_layer_depths,
#            name='Encoder'):
# def inputs_to_feature_vector(inputs, feature_length, model_config):
# def decode(z,
#            model_config,
#            spatial_dims,
#            fc_layer_depths,
#            conv_layer_depths,
#            output_dim,
#            name='Decoder'):
# def residual_layer(inputs, num_outputs, model_config):
# 
# Path: ldif/util/math_util.py
# def int_log2(i):
# def nonzero_mean(tensor):
# def increase_frequency(t, out_dim, flatten=False, interleave=True):


import tensorflow as tf
from tensorflow.contrib import layers
from ldif.util import net_util
from ldif.util import math_util
  Returns:
    Tensor with shape [batch_size, sample_count, 1].
  """
  if model_config.hparams.hyo == 't':
    samples = math_util.nerfify(samples, 10, flatten=True, interleave=True)
    sample_len = 60
  else:
    sample_len = 3
  if model_config.hparams.dd == 't':
    tf.logging.info(
        'BID0: Running SS Occnet Decoder with input shapes embedding=%s, samples=%s',
        repr(embedding.get_shape().as_list()),
        repr(samples.get_shape().as_list()))
    ensure_shape(embedding, [1, -1])
    ensure_shape(samples, [1, -1, 3])
    vals = one_shape_occnet_decoder(
        remove_batch_dim(embedding), remove_batch_dim(samples), apply_sigmoid,
        model_config)
    return add_batch_dim(vals)
  batch_size, embedding_length = embedding.get_shape().as_list()
  ensure_shape(embedding, [batch_size, embedding_length])
  ensure_shape(samples, [batch_size, -1, sample_len])
  # Debugging:
  vals = multishape_occnet_decoder(embedding, samples, apply_sigmoid,
                                   model_config)
  return vals


def occnet_encoder(inputs, model_config):
  ensure_rank(inputs, 5)

# Path: ldif/util/net_util.py
# def twin_inference(inference_fun, observation, element_count,
#                    flat_element_length, model_config):
# def get_normalizer_and_mode(model_config):
# def conv_layer(inputs, depth, model_config):
# def maxpool2x2_layer(inputs):
# def down_layer(inputs, depth, model_config):
# def up_layer(inputs, spatial_dims, depth, model_config):
# def encode(inputs,
#            model_config,
#            conv_layer_depths,
#            fc_layer_depths,
#            name='Encoder'):
# def inputs_to_feature_vector(inputs, feature_length, model_config):
# def decode(z,
#            model_config,
#            spatial_dims,
#            fc_layer_depths,
#            conv_layer_depths,
#            output_dim,
#            name='Decoder'):
# def residual_layer(inputs, num_outputs, model_config):
# 
# Path: ldif/util/math_util.py
# def int_log2(i):
# def nonzero_mean(tensor):
# def increase_frequency(t, out_dim, flatten=False, interleave=True):


# Path: ldif/nets/occnet.py
import tensorflow as tf
from tensorflow.contrib import layers
from ldif.util import net_util
from ldif.util import math_util

  Returns:
    Tensor with shape [batch_size, sample_count, 1].
  """
  if model_config.hparams.hyo == 't':
    samples = math_util.nerfify(samples, 10, flatten=True, interleave=True)
    sample_len = 60
  else:
    sample_len = 3
  if model_config.hparams.dd == 't':
    tf.logging.info(
        'BID0: Running SS Occnet Decoder with input shapes embedding=%s, samples=%s',
        repr(embedding.get_shape().as_list()),
        repr(samples.get_shape().as_list()))
    ensure_shape(embedding, [1, -1])
    ensure_shape(samples, [1, -1, 3])
    vals = one_shape_occnet_decoder(
        remove_batch_dim(embedding), remove_batch_dim(samples), apply_sigmoid,
        model_config)
    return add_batch_dim(vals)
  batch_size, embedding_length = embedding.get_shape().as_list()
  ensure_shape(embedding, [batch_size, embedding_length])
  ensure_shape(samples, [batch_size, -1, sample_len])
  # Debugging:
  vals = multishape_occnet_decoder(embedding, samples, apply_sigmoid,
                                   model_config)
  return vals


def occnet_encoder(inputs, model_config):
  ensure_rank(inputs, 5)

  return net_util.inputs_to_feature_vector(inputs, 256, model_config)