def METHOD_NAME(input_dir, batch_size, training=True, num_epochs=None,
                  random_seed=None, prefetch_buffer_size=1):
  """Generates an input_fn to use as input to estimator or experiment.
  Combines positive review and negative review datasets into one single dataset.
  Applies shuffling and batching by sequence length.
  Args:
    input_dir: `str`, path to input data.
    batch_size: `int`, size of input batches.
    training: `bool`, whether the data is training data or validation data.
    num_epochs: `int`, number of epochs to repeat the dataset.
    random_seed: `int`, seed to use for randomization.
    prefetch_buffer_size: `int`, buffer size to use to prefetch data.
  Returns:
    Input function.
  """
  def _get_shape(features, labels):
    del labels  # Unused.
    return features[constants.SEQUENCE_LENGTH]
  def _input_fn():
    """Train/eval input function."""
    schema = utils.get_processed_data_schema()
    def _parse_input(record):
      record = tf.parse_single_example(serialized=record, features=schema)
      labels = record.pop(constants.LABELS)
      features = parse_raw_text(tf.reshape(record.pop(constants.REVIEW), [-1,]))
      features[constants.TOKENS] = tf.sparse_reshape(
          features[constants.TOKENS], shape=[-1])
      return features, labels
    filenames = tf.train.match_filenames_once(input_dir)
    dataset = tf.data.TFRecordDataset(filenames)
    dataset = dataset.map(_parse_input,
                          num_parallel_calls=multiprocessing.cpu_count())
    dataset = dataset.shuffle(
        buffer_size=_SHUFFLE_BUFFER_SIZE, seed=random_seed)
    # Groups records by sequence length.
    boundaries = np.arange(
        _BUCKET_MIN_BOUNDARY,
        _BUCKET_MAX_BOUNDARY,
        _BUCKET_LENGTH_STEP)
    dataset = dataset.apply(group_by_sequence_length_sparse(
        _get_shape, boundaries, batch_size))
    # Repeats dataset.
    dataset = dataset.repeat(num_epochs if training else 1)
    dataset = dataset.prefetch(buffer_size=prefetch_buffer_size)
    return dataset
  return _input_fn