import tensorflow as tf

    def _serialize_dataset(self, tasks, is_training, split):
        """Write out the dataset as tfrecords."""
        dataset_name = "_".join(sorted([task.name for task in tasks]))
        dataset_name += "_" + split
        dataset_prefix = os.path.join(self._config.preprocessed_data_dir, dataset_name)
        tfrecords_path = dataset_prefix + ".tfrecord"
        metadata_path = dataset_prefix + ".metadata"
        batch_size = self._config.train_batch_size if is_training else self._config.eval_batch_size

        utils.log("Loading dataset", dataset_name)
        n_examples = None
        if self._config.use_tfrecords_if_existing and tf.gfile.Exists(metadata_path):
            n_examples = utils.load_json(metadata_path)["n_examples"]

        if n_examples is None:
            utils.log("Existing tfrecords not found so creating")
            examples = []

            for task in tasks:
                task_examples = task.get_examples(split)
                examples += task_examples

