# Path: utils/sent_utils.py
# def inf_batch_iterator(n, batch_size, shuffle=True, include_last=False):
#   while True:
#     for indices in iterate_minibatches_indices(n, batch_size,
#                                                shuffle, include_last):
#       yield indices
# 
# def iterate_minibatches_indices(n, batch_size, shuffle=False,
#                                 include_last=True):
#   indices = np.arange(n)
# 
#   num_batches = n // batch_size
#   if include_last:
#     num_batches += (n % batch_size != 0)
# 
#   if num_batches == 0:
#     num_batches = 1
# 
#   if shuffle:
#     np.random.shuffle(indices)
# 
#   for batch_idx in range(num_batches):
#     batch_indices = indices[batch_idx * batch_size:
#                             (batch_idx + 1) * batch_size]
#     yield batch_indices
# 
# Path: utils/common_utils.py
# def log(msg):
#   if msg[-1] != '\n':
#     msg += '\n'
#   sys.stderr.write(msg)
#   sys.stderr.flush()


from utils.sent_utils import inf_batch_iterator, iterate_minibatches_indices
from utils.common_utils import log
import sklearn.linear_model as linear_model
import tensorflow as tf
import numpy as np
                                  kernel_regularizer=l2_reg))
  if norm:
    model.add(tf.keras.layers.Lambda(lambda x: tf.nn.l2_normalize(x, axis=-1),
                                     name='reg_norm'))
  model.compile(tf.keras.optimizers.Adam(lr), loss='mse', metric='mse')
  model.fit(x, y, batch_size=batch_size, verbose=1, epochs=epochs)

  def mapping(z):
    mapped = model.predict(z, batch_size=1024)
    tf.keras.backend.clear_session()
    return mapped

  return mapping


class Generator(object):
  def __init__(self, output_dim, activation=tf.nn.relu):
    self.fc1 = tf.keras.layers.Dense(output_dim, activation=activation,
                                     name='gen_fc1')
    # self.fc2 = tf.keras.layers.Dense(output_dim, activation=activation,
    #                                  name='gen_fc2')
    self.output = tf.keras.layers.Dense(output_dim, name='gen_output')

  def forward(self, x):
    x = self.fc1(x)
    # x = self.fc2(x)
    x = self.output(x)
    return x



# Path: utils/sent_utils.py
# def inf_batch_iterator(n, batch_size, shuffle=True, include_last=False):
#   while True:
#     for indices in iterate_minibatches_indices(n, batch_size,
#                                                shuffle, include_last):
#       yield indices
# 
# def iterate_minibatches_indices(n, batch_size, shuffle=False,
#                                 include_last=True):
#   indices = np.arange(n)
# 
#   num_batches = n // batch_size
#   if include_last:
#     num_batches += (n % batch_size != 0)
# 
#   if num_batches == 0:
#     num_batches = 1
# 
#   if shuffle:
#     np.random.shuffle(indices)
# 
#   for batch_idx in range(num_batches):
#     batch_indices = indices[batch_idx * batch_size:
#                             (batch_idx + 1) * batch_size]
#     yield batch_indices
# 
# Path: utils/common_utils.py
# def log(msg):
#   if msg[-1] != '\n':
#     msg += '\n'
#   sys.stderr.write(msg)
#   sys.stderr.flush()


# Path: train_feature_mapper.py
from utils.sent_utils import inf_batch_iterator, iterate_minibatches_indices
from utils.common_utils import log
import sklearn.linear_model as linear_model
import tensorflow as tf
import numpy as np

                                  kernel_regularizer=l2_reg))
  if norm:
    model.add(tf.keras.layers.Lambda(lambda x: tf.nn.l2_normalize(x, axis=-1),
                                     name='reg_norm'))
  model.compile(tf.keras.optimizers.Adam(lr), loss='mse', metric='mse')
  model.fit(x, y, batch_size=batch_size, verbose=1, epochs=epochs)

  def mapping(z):
    mapped = model.predict(z, batch_size=1024)
    tf.keras.backend.clear_session()
    return mapped

  return mapping


class Generator(object):
  def __init__(self, output_dim, activation=tf.nn.relu):
    self.fc1 = tf.keras.layers.Dense(output_dim, activation=activation,
                                     name='gen_fc1')
    # self.fc2 = tf.keras.layers.Dense(output_dim, activation=activation,
    #                                  name='gen_fc2')
    self.output = tf.keras.layers.Dense(output_dim, name='gen_output')

  def forward(self, x):
    x = self.fc1(x)
    # x = self.fc2(x)
    x = self.output(x)
    return x



class Discriminator(object):