import tensorflow as tf

      reset: Whether to reset the datasets.

    Returns:
      data: a batch of data from either the train or test set.
    """
    with datasets.unlocked:
        datasets.train = datasets.train.make_one_shot_iterator()
        datasets.test = datasets.test.make_one_shot_iterator()
    data = tf.cond(
        tf.equal(phase, 'train'),
        datasets.train.get_next,
        datasets.test.get_next)
    if not isinstance(data, dict):
        data = {'data': data}
    if 'length' not in data:
        example = data[list(data.keys())[0]]
        data['length'] = (
                tf.zeros((tf.shape(example)[0],), tf.int32) + tf.shape(example)[1])
