def generate_samples(self, data_dir, tmp_dir, dataset_split):
    """Generate samples of text and label pairs.

    Each yielded dict will be a single example. The inputs should be raw text.
    The label should be an int in [0, self.num_classes).

    Args:
      data_dir: final data directory. Typically only used in this method to copy
        over user-supplied vocab files (for example, if vocab_type ==
        VocabType.TOKEN).
      tmp_dir: temporary directory that you can use for downloading and scratch.
      dataset_split: problem.DatasetSplit, which data split to generate samples
        for (for example, training and evaluation).

    Returns:
      sample generator.
    """
    example_filed = 'sentence'
    examples_for_vocab, train, val, test = load_examples(
        tmp_dir, self.train_proportion, self.validation_proportion)
    _build_vocab(
        examples_for_vocab, example_filed, data_dir, self.vocab_filename)
    if dataset_split == problem.DatasetSplit.TRAIN:
      examples = train

    elif dataset_split == problem.DatasetSplit.EVAL:
      examples = val

    elif dataset_split == problem.DatasetSplit.TEST:
      examples = test

    def _generate_samples():
      for example in examples:
        index = int(example['verb_index']) - 1
        inputs = example[example_filed].split()[:index]
        yield {
            'inputs': ' '.join(inputs),
            'label': _LABEL_DICT[example['verb_pos']]
        }

    return _generate_samples()
Generate samples of text and label pairs.

    Each yielded dict will be a single example. The inputs should be raw text.
    The label should be an int in [0, self.num_classes).

    Args:
      data_dir: final data directory. Typically only used in this method to copy
        over user-supplied vocab files (for example, if vocab_type ==
        VocabType.TOKEN).
      tmp_dir: temporary directory that you can use for downloading and scratch.
      dataset_split: problem.DatasetSplit, which data split to generate samples
        for (for example, training and evaluation).

    Returns:
      sample generator.
    
tensor2tensor/data_generators/subject_verb_agreement.py