# Path: moonlight/models/base/glyph_patches.py
# WEIGHT_COLUMN_NAME = 'weight'
# FLAGS = flags.FLAGS
# def read_patch_dimensions():
# def input_fn(input_patches):
#   def parser(record):
# def _augment(patch):
# def _augment_shift(patch):
#     def shift_left():
#     def shift_right():
#     def identity():
# def _shift_left(patch):
# def _shift_right(patch):
# def _augment_rotation(patch):
# def serving_fn():
# def create_patch_feature_column():
# def multiclass_binary_metric(class_number, binary_metric, labels, predictions):
# def metrics_fn(features, labels, predictions):
# def train_and_evaluate(estimator):


import tempfile
import numpy as np
import tensorflow as tf
from absl import flags
from moonlight.models.base import glyph_patches
from tensorflow.python.lib.io import tf_record
            batch[0]['patch'],
            np.arange(height * width).reshape(
                (1, height, width)).repeat(3, axis=0))
        self.assertAllEqual(batch[1], [label, label, label])

  def testShiftLeft(self):
    with self.test_session():
      self.assertAllEqual(
          # pyformat: disable
          glyph_patches._shift_left([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10,
                                                                  11]]).eval(),
          [[1, 2, 3, 3], [5, 6, 7, 7], [9, 10, 11, 11]])

  def testShiftRight(self):
    with self.test_session():
      self.assertAllEqual(
          # pyformat: disable
          glyph_patches._shift_right([[0, 1, 2, 3], [4, 5, 6, 7],
                                      [8, 9, 10, 11]]).eval(),
          [[0, 0, 1, 2], [4, 4, 5, 6], [8, 8, 9, 10]])

  def testMulticlassBinaryMetric(self):
    # pyformat: disable
    # pylint: disable=bad-whitespace
    labels =                     tf.constant([1, 1, 3, 2, 2, 2, 2])
    predictions = dict(class_ids=tf.constant([1, 3, 2, 2, 4, 3, 2]))
    _, precision_1 = glyph_patches.multiclass_binary_metric(
        1, tf.metrics.precision, labels, predictions)
    _, recall_1 = glyph_patches.multiclass_binary_metric(
        1, tf.metrics.recall, labels, predictions)

# Path: moonlight/models/base/glyph_patches.py
# WEIGHT_COLUMN_NAME = 'weight'
# FLAGS = flags.FLAGS
# def read_patch_dimensions():
# def input_fn(input_patches):
#   def parser(record):
# def _augment(patch):
# def _augment_shift(patch):
#     def shift_left():
#     def shift_right():
#     def identity():
# def _shift_left(patch):
# def _shift_right(patch):
# def _augment_rotation(patch):
# def serving_fn():
# def create_patch_feature_column():
# def multiclass_binary_metric(class_number, binary_metric, labels, predictions):
# def metrics_fn(features, labels, predictions):
# def train_and_evaluate(estimator):


# Path: moonlight/models/base/glyph_patches_test.py
import tempfile
import numpy as np
import tensorflow as tf
from absl import flags
from moonlight.models.base import glyph_patches
from tensorflow.python.lib.io import tf_record

            batch[0]['patch'],
            np.arange(height * width).reshape(
                (1, height, width)).repeat(3, axis=0))
        self.assertAllEqual(batch[1], [label, label, label])

  def testShiftLeft(self):
    with self.test_session():
      self.assertAllEqual(
          # pyformat: disable
          glyph_patches._shift_left([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10,
                                                                  11]]).eval(),
          [[1, 2, 3, 3], [5, 6, 7, 7], [9, 10, 11, 11]])

  def testShiftRight(self):
    with self.test_session():
      self.assertAllEqual(
          # pyformat: disable
          glyph_patches._shift_right([[0, 1, 2, 3], [4, 5, 6, 7],
                                      [8, 9, 10, 11]]).eval(),
          [[0, 0, 1, 2], [4, 4, 5, 6], [8, 8, 9, 10]])

  def testMulticlassBinaryMetric(self):
    # pyformat: disable
    # pylint: disable=bad-whitespace
    labels =                     tf.constant([1, 1, 3, 2, 2, 2, 2])
    predictions = dict(class_ids=tf.constant([1, 3, 2, 2, 4, 3, 2]))
    _, precision_1 = glyph_patches.multiclass_binary_metric(
        1, tf.metrics.precision, labels, predictions)
    _, recall_1 = glyph_patches.multiclass_binary_metric(
        1, tf.metrics.recall, labels, predictions)

    _, precision_2 = glyph_patches.multiclass_binary_metric(