# Path: ldif/util/line_util.py
# def line_to_image(line_parameters, height, width, falloff=2.0):
# def fractional_vector_projection(e0, e1, p, falloff=2.0):
# def rotate_about_point(angle_of_rotation, point, to_rotate):
# def union_of_line_drawings(lines):
# def network_line_parameters_to_line(line_parameters, height, width):
# 
# 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):


import tensorflow as tf
from ldif.util import line_util
from ldif.util import net_util
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Lint as: python3
"""Nets for predicting 2D lines."""


# LDIF is an internal package, should be imported last.
# pylint: disable=g-bad-import-order
# pylint: enable=g-bad-import-order


def lstm_lines_transcoder(inputs, model_config):
  """A model that uses an LSTM to predict a sequence of lines."""
  batch_size = model_config.hparams.bs
  height = model_config.hparams.h
  width = model_config.hparams.w
  conv_layer_depths = [16, 32, 64, 128, 128]
  number_of_lines = model_config.hparams.sc  # Was 4!
  number_of_layers = model_config.hparams.cc
  line_embedding_size = 5
  encoded_image_length = 1024
  # embedding_size = line_embedding_size * number_of_lines
  lstm_size = model_config.hparams.hlw
  reencode_partial_outputs = True


# Path: ldif/util/line_util.py
# def line_to_image(line_parameters, height, width, falloff=2.0):
# def fractional_vector_projection(e0, e1, p, falloff=2.0):
# def rotate_about_point(angle_of_rotation, point, to_rotate):
# def union_of_line_drawings(lines):
# def network_line_parameters_to_line(line_parameters, height, width):
# 
# 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/nets/linenet.py
import tensorflow as tf
from ldif.util import line_util
from ldif.util import net_util

#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Lint as: python3
"""Nets for predicting 2D lines."""


# LDIF is an internal package, should be imported last.
# pylint: disable=g-bad-import-order
# pylint: enable=g-bad-import-order


def lstm_lines_transcoder(inputs, model_config):
  """A model that uses an LSTM to predict a sequence of lines."""
  batch_size = model_config.hparams.bs
  height = model_config.hparams.h
  width = model_config.hparams.w
  conv_layer_depths = [16, 32, 64, 128, 128]
  number_of_lines = model_config.hparams.sc  # Was 4!
  number_of_layers = model_config.hparams.cc
  line_embedding_size = 5
  encoded_image_length = 1024
  # embedding_size = line_embedding_size * number_of_lines
  lstm_size = model_config.hparams.hlw
  reencode_partial_outputs = True


  encoded_image, _, _ = net_util.encode(