# Path: vmoe/data/pp_ops.py
# class InKeyOutKey(object):
#   def __init__(self, indefault='image', outdefault='image'):
#   def __call__(self, orig_get_pp_fn):
#     def get_ikok_pp_fn(*args, key=None,
#                        inkey=self.indefault, outkey=self.outdefault, **kw):
#       def _ikok_pp_fn(data):
# def central_crop(crop_size):
#   def _crop(image):
# def copy(inkey, outkey):
#   def _copy(data):
# def decode(channels=3):
#   def _decode(image):
# def decode_jpeg_and_inception_crop(resize_size=None, area_min=5, area_max=100):
#   def _inception_crop(image_data):  # pylint: disable=missing-docstring
# def flip_lr():
#   def _random_flip_lr_pp(image):
# def inception_crop(resize_size=None, area_min=5, area_max=100,
#                    resize_method='bilinear'):
#   def _inception_crop(image):  # pylint: disable=missing-docstring
# def keep(*keys):
#   def _keep(data):
# def onehot(depth, multi=True, on=1.0, off=0.0):
#   def _onehot(label):
# def randaug(num_layers: int = 2, magnitude: int = 10):
#   def _randaug(image):
# def resize(resize_size, resize_method='bilinear'):
#   def _resize(image):
# def resize_small(smaller_size):
#   def _resize_small(image):  # pylint: disable=missing-docstring
# def value_range(vmin, vmax, in_min=0, in_max=255.0, clip_values=False):
#   def _value_range(image):


import io
import imageio
import numpy as np
import tensorflow.compat.v1 as tf
from vmoe.data import pp_ops
    data = {'image': f.getvalue()}
    output = pp_ops.decode_jpeg_and_inception_crop(128)(data)['image']
    self.assertEqual(output.shape, (128, 128, 3))

  def test_inception_crop(self):
    image = np.random.randint(0, 256, [224, 224, 3]).astype('uint8')
    output = pp_ops.inception_crop(128)({'image': image})['image'].numpy()
    self.assertEqual(output.shape, (128, 128, 3))

  def test_central_crop(self):
    data = self.get_data()
    data = pp_ops.central_crop([120, 80])(data)
    self.assertEqual(data['image'].numpy().shape, (120, 80, 3))

  def test_flip_lr(self):
    data = self.get_data()
    data_after_pp = pp_ops.flip_lr()(data)
    self.assertTrue(
        np.all(data['image'].numpy() == data_after_pp['image'].numpy()) or
        np.all(data['image'][:, ::-1].numpy() ==
               data_after_pp['image'].numpy()))

  def test_value_range(self):
    data = self.get_data()
    data = pp_ops.value_range(-0.5, 0.5)(data)
    self.assertLessEqual(np.max(data['image'].numpy()), 0.5)
    self.assertGreaterEqual(np.min(data['image'].numpy()), -0.5)

  def test_value_range_custom_input_range(self):
    data = self.get_data()

# Path: vmoe/data/pp_ops.py
# class InKeyOutKey(object):
#   def __init__(self, indefault='image', outdefault='image'):
#   def __call__(self, orig_get_pp_fn):
#     def get_ikok_pp_fn(*args, key=None,
#                        inkey=self.indefault, outkey=self.outdefault, **kw):
#       def _ikok_pp_fn(data):
# def central_crop(crop_size):
#   def _crop(image):
# def copy(inkey, outkey):
#   def _copy(data):
# def decode(channels=3):
#   def _decode(image):
# def decode_jpeg_and_inception_crop(resize_size=None, area_min=5, area_max=100):
#   def _inception_crop(image_data):  # pylint: disable=missing-docstring
# def flip_lr():
#   def _random_flip_lr_pp(image):
# def inception_crop(resize_size=None, area_min=5, area_max=100,
#                    resize_method='bilinear'):
#   def _inception_crop(image):  # pylint: disable=missing-docstring
# def keep(*keys):
#   def _keep(data):
# def onehot(depth, multi=True, on=1.0, off=0.0):
#   def _onehot(label):
# def randaug(num_layers: int = 2, magnitude: int = 10):
#   def _randaug(image):
# def resize(resize_size, resize_method='bilinear'):
#   def _resize(image):
# def resize_small(smaller_size):
#   def _resize_small(image):  # pylint: disable=missing-docstring
# def value_range(vmin, vmax, in_min=0, in_max=255.0, clip_values=False):
#   def _value_range(image):


# Path: vmoe/data/pp_ops_test.py
import io
import imageio
import numpy as np
import tensorflow.compat.v1 as tf
from vmoe.data import pp_ops

    data = {'image': f.getvalue()}
    output = pp_ops.decode_jpeg_and_inception_crop(128)(data)['image']
    self.assertEqual(output.shape, (128, 128, 3))

  def test_inception_crop(self):
    image = np.random.randint(0, 256, [224, 224, 3]).astype('uint8')
    output = pp_ops.inception_crop(128)({'image': image})['image'].numpy()
    self.assertEqual(output.shape, (128, 128, 3))

  def test_central_crop(self):
    data = self.get_data()
    data = pp_ops.central_crop([120, 80])(data)
    self.assertEqual(data['image'].numpy().shape, (120, 80, 3))

  def test_flip_lr(self):
    data = self.get_data()
    data_after_pp = pp_ops.flip_lr()(data)
    self.assertTrue(
        np.all(data['image'].numpy() == data_after_pp['image'].numpy()) or
        np.all(data['image'][:, ::-1].numpy() ==
               data_after_pp['image'].numpy()))

  def test_value_range(self):
    data = self.get_data()
    data = pp_ops.value_range(-0.5, 0.5)(data)
    self.assertLessEqual(np.max(data['image'].numpy()), 0.5)
    self.assertGreaterEqual(np.min(data['image'].numpy()), -0.5)

  def test_value_range_custom_input_range(self):
    data = self.get_data()

    data = pp_ops.value_range(-0.5, 0.5, -256, 255, True)(data)