# Path: tf_slim/data/tfexample_decoder.py
# class ItemHandler(object):
# class ItemHandlerCallback(ItemHandler):
# class BoundingBox(ItemHandler):
# class Tensor(ItemHandler):
# class LookupTensor(Tensor):
# class BackupHandler(ItemHandler):
# class SparseTensor(ItemHandler):
# class Image(ItemHandler):
# class BoundingBoxSequence(ItemHandler):
# class NumBoxesSequence(ItemHandler):
# class KeypointsSequence(ItemHandler):
# class TFExampleDecoder(data_decoder.DataDecoder):
# class TFSequenceExampleDecoder(data_decoder.DataDecoder):
#   def __init__(self, keys):
#   def keys(self):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, keys, func):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, keys=None, prefix=''):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, tensor_key, shape_keys=None, shape=None, default_value=0):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self,
#                tensor_key,
#                table,
#                shape_keys=None,
#                shape=None,
#                default_value=''):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, handler, backup):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self,
#                indices_key=None,
#                values_key=None,
#                shape_key=None,
#                shape=None,
#                densify=False,
#                default_value=0):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self,
#                image_key=None,
#                format_key=None,
#                shape=None,
#                channels=3,
#                dtype=dtypes.uint8,
#                repeated=False,
#                dct_method=''):
#   def tensors_to_item(self, keys_to_tensors):
#   def _decode(self, image_buffer, image_format):
#     def decode_image():
#     def decode_jpeg():
#     def check_jpeg():
#     def decode_raw():
#   def __init__(self, keys=None, prefix=None, return_dense=True,
#                default_value=-1.0):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, keys=None, check_consistency=True):
#   def tensors_to_item(self, keys_to_tensors):
#     def _compute_num_boxes(tensor):
#   def __init__(self, keys=None, prefix=None, return_dense=True,
#                default_value=-1.0):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, keys_to_features, items_to_handlers):
#   def list_items(self):
#   def decode(self, serialized_example, items=None):
#   def __init__(self, keys_to_context_features, keys_to_sequence_features,
#                items_to_handlers):
#   def list_items(self):
#   def decode(self, serialized_example, items=None):


import sys
import numpy as np
import tensorflow.compat.v1 as tf
from tf_slim.data import tfexample_decoder
from google.protobuf import text_format
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import image_ops
from tensorflow.python.ops import lookup_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import parsing_ops
from tensorflow.python.platform import test
        serialized image and a feature key 'image/format' set to the image
        encoding format ['jpeg', 'JPEG', 'png', 'PNG', 'raw'].
    """
    assert image_format in ['raw', 'RAW'] or image_dtype == np.uint8
    num_pixels = image_shape[0] * image_shape[1] * image_shape[2]
    image = np.linspace(
        0, num_pixels - 1,
        num=num_pixels).reshape(image_shape).astype(image_dtype)
    tf_encoded = self._Encoder(image, image_format)
    example = tf.train.Example(
        features=tf.train.Features(
            feature={
                'image/encoded': self._EncodedBytesFeature(tf_encoded),
                'image/format': self._StringFeature(image_format)
            }))

    return image, example.SerializeToString()

  def DecodeExample(self, serialized_example, item_handler, image_format):
    """Decodes the given serialized example with the specified item handler.

    Args:
      serialized_example: a serialized TF example string.
      item_handler: the item handler used to decode the image.
      image_format: the image format being decoded.

    Returns:
      the decoded image found in the serialized Example.
    """
    serialized_example = array_ops.reshape(serialized_example, shape=[])

# Path: tf_slim/data/tfexample_decoder.py
# class ItemHandler(object):
# class ItemHandlerCallback(ItemHandler):
# class BoundingBox(ItemHandler):
# class Tensor(ItemHandler):
# class LookupTensor(Tensor):
# class BackupHandler(ItemHandler):
# class SparseTensor(ItemHandler):
# class Image(ItemHandler):
# class BoundingBoxSequence(ItemHandler):
# class NumBoxesSequence(ItemHandler):
# class KeypointsSequence(ItemHandler):
# class TFExampleDecoder(data_decoder.DataDecoder):
# class TFSequenceExampleDecoder(data_decoder.DataDecoder):
#   def __init__(self, keys):
#   def keys(self):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, keys, func):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, keys=None, prefix=''):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, tensor_key, shape_keys=None, shape=None, default_value=0):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self,
#                tensor_key,
#                table,
#                shape_keys=None,
#                shape=None,
#                default_value=''):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, handler, backup):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self,
#                indices_key=None,
#                values_key=None,
#                shape_key=None,
#                shape=None,
#                densify=False,
#                default_value=0):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self,
#                image_key=None,
#                format_key=None,
#                shape=None,
#                channels=3,
#                dtype=dtypes.uint8,
#                repeated=False,
#                dct_method=''):
#   def tensors_to_item(self, keys_to_tensors):
#   def _decode(self, image_buffer, image_format):
#     def decode_image():
#     def decode_jpeg():
#     def check_jpeg():
#     def decode_raw():
#   def __init__(self, keys=None, prefix=None, return_dense=True,
#                default_value=-1.0):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, keys=None, check_consistency=True):
#   def tensors_to_item(self, keys_to_tensors):
#     def _compute_num_boxes(tensor):
#   def __init__(self, keys=None, prefix=None, return_dense=True,
#                default_value=-1.0):
#   def tensors_to_item(self, keys_to_tensors):
#   def __init__(self, keys_to_features, items_to_handlers):
#   def list_items(self):
#   def decode(self, serialized_example, items=None):
#   def __init__(self, keys_to_context_features, keys_to_sequence_features,
#                items_to_handlers):
#   def list_items(self):
#   def decode(self, serialized_example, items=None):


# Path: tf_slim/data/tfexample_decoder_test.py
import sys
import numpy as np
import tensorflow.compat.v1 as tf
from tf_slim.data import tfexample_decoder
from google.protobuf import text_format
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import image_ops
from tensorflow.python.ops import lookup_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import parsing_ops
from tensorflow.python.platform import test

        serialized image and a feature key 'image/format' set to the image
        encoding format ['jpeg', 'JPEG', 'png', 'PNG', 'raw'].
    """
    assert image_format in ['raw', 'RAW'] or image_dtype == np.uint8
    num_pixels = image_shape[0] * image_shape[1] * image_shape[2]
    image = np.linspace(
        0, num_pixels - 1,
        num=num_pixels).reshape(image_shape).astype(image_dtype)
    tf_encoded = self._Encoder(image, image_format)
    example = tf.train.Example(
        features=tf.train.Features(
            feature={
                'image/encoded': self._EncodedBytesFeature(tf_encoded),
                'image/format': self._StringFeature(image_format)
            }))

    return image, example.SerializeToString()

  def DecodeExample(self, serialized_example, item_handler, image_format):
    """Decodes the given serialized example with the specified item handler.

    Args:
      serialized_example: a serialized TF example string.
      item_handler: the item handler used to decode the image.
      image_format: the image format being decoded.

    Returns:
      the decoded image found in the serialized Example.
    """
    serialized_example = array_ops.reshape(serialized_example, shape=[])

    decoder = tfexample_decoder.TFExampleDecoder(