# Path: tf_slim/queues.py
# class NestedQueueRunnerError(Exception):
# def QueueRunners(session):
# 
# Path: tf_slim/data/dataset.py
# class Dataset(object):
#   def __init__(self, data_sources, reader, decoder, num_samples,
#                items_to_descriptions, **kwargs):
# 
# Path: tf_slim/data/dataset_data_provider.py
# class DatasetDataProvider(data_provider.DataProvider):
#   def __init__(self,
#                dataset,
#                num_readers=1,
#                reader_kwargs=None,
#                shuffle=True,
#                num_epochs=None,
#                common_queue_capacity=256,
#                common_queue_min=128,
#                record_key='record_key',
#                seed=None,
#                scope=None):
# 
# Path: tf_slim/data/test_utils.py
# def _encoded_int64_feature(ndarray):
# def _encoded_bytes_feature(tf_encoded):
#   def string_to_bytes(value):
# def _string_feature(value):
# def _encoder(image, image_format):
# def generate_image(image_shape, image_format='jpeg', label=0):
# def create_tfrecord_files(output_dir, num_files=3, num_records_per_file=10):
# 
# 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 tempfile
import tensorflow.compat.v1 as tf
from tf_slim import queues
from tf_slim.data import dataset
from tf_slim.data import dataset_data_provider
from tf_slim.data import test_utils
from tf_slim.data import tfexample_decoder
from tensorflow.python.client import session
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import image_ops
from tensorflow.python.ops import io_ops
from tensorflow.python.ops import parsing_ops
from tensorflow.python.platform import gfile
from tensorflow.python.platform import test

def _create_tfrecord_dataset(tmpdir):
  if not gfile.Exists(tmpdir):
    gfile.MakeDirs(tmpdir)

  data_sources = test_utils.create_tfrecord_files(tmpdir, num_files=1)

  keys_to_features = {
      'image/encoded':
          parsing_ops.FixedLenFeature(
              shape=(), dtype=dtypes.string, default_value=''),
      'image/format':
          parsing_ops.FixedLenFeature(
              shape=(), dtype=dtypes.string, default_value='jpeg'),
      'image/class/label':
          parsing_ops.FixedLenFeature(
              shape=[1],
              dtype=dtypes.int64,
              default_value=array_ops.zeros(
                  [1], dtype=dtypes.int64))
  }

  items_to_handlers = {
      'image': tfexample_decoder.Image(),
      'label': tfexample_decoder.Tensor('image/class/label'),
  }

  decoder = tfexample_decoder.TFExampleDecoder(keys_to_features,
                                               items_to_handlers)


# Path: tf_slim/queues.py
# class NestedQueueRunnerError(Exception):
# def QueueRunners(session):
# 
# Path: tf_slim/data/dataset.py
# class Dataset(object):
#   def __init__(self, data_sources, reader, decoder, num_samples,
#                items_to_descriptions, **kwargs):
# 
# Path: tf_slim/data/dataset_data_provider.py
# class DatasetDataProvider(data_provider.DataProvider):
#   def __init__(self,
#                dataset,
#                num_readers=1,
#                reader_kwargs=None,
#                shuffle=True,
#                num_epochs=None,
#                common_queue_capacity=256,
#                common_queue_min=128,
#                record_key='record_key',
#                seed=None,
#                scope=None):
# 
# Path: tf_slim/data/test_utils.py
# def _encoded_int64_feature(ndarray):
# def _encoded_bytes_feature(tf_encoded):
#   def string_to_bytes(value):
# def _string_feature(value):
# def _encoder(image, image_format):
# def generate_image(image_shape, image_format='jpeg', label=0):
# def create_tfrecord_files(output_dir, num_files=3, num_records_per_file=10):
# 
# 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/dataset_data_provider_test.py
import tempfile
import tensorflow.compat.v1 as tf
from tf_slim import queues
from tf_slim.data import dataset
from tf_slim.data import dataset_data_provider
from tf_slim.data import test_utils
from tf_slim.data import tfexample_decoder
from tensorflow.python.client import session
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import image_ops
from tensorflow.python.ops import io_ops
from tensorflow.python.ops import parsing_ops
from tensorflow.python.platform import gfile
from tensorflow.python.platform import test


def _create_tfrecord_dataset(tmpdir):
  if not gfile.Exists(tmpdir):
    gfile.MakeDirs(tmpdir)

  data_sources = test_utils.create_tfrecord_files(tmpdir, num_files=1)

  keys_to_features = {
      'image/encoded':
          parsing_ops.FixedLenFeature(
              shape=(), dtype=dtypes.string, default_value=''),
      'image/format':
          parsing_ops.FixedLenFeature(
              shape=(), dtype=dtypes.string, default_value='jpeg'),
      'image/class/label':
          parsing_ops.FixedLenFeature(
              shape=[1],
              dtype=dtypes.int64,
              default_value=array_ops.zeros(
                  [1], dtype=dtypes.int64))
  }

  items_to_handlers = {
      'image': tfexample_decoder.Image(),
      'label': tfexample_decoder.Tensor('image/class/label'),
  }

  decoder = tfexample_decoder.TFExampleDecoder(keys_to_features,
                                               items_to_handlers)


  return dataset.Dataset(