def save_dataset(self, file_name):
    """Saves the current generated data to a file."""
    assert self._data_pairs, "No data to save, call .get_data_pairs()"
    output_path = os.path.join(self.save_directory, file_name)
    with tf.io.gfile.GFile(output_path, "w") as outfile:
      dataset_representation = {
          "grid_size": self._world.grid_size,
          "type_grammar": self._type_grammar,
          "exclude_type_grammar": self._exclude_type_grammar,
          "grammar": self._grammar.__str__(),
          "min_object_size": self._object_vocabulary.smallest_size,
          "max_object_size": self._object_vocabulary.largest_size,
          "max_recursion": self.max_recursion,
          "percentage_train": self._percentage_train,
          "examples": {key: values for key, values in self._data_pairs.items()}
      }
      dataset_representation.update(self._vocabulary.to_representation())
      if self._type_grammar.endswith("simple_intrans"):
        dataset_representation["transitive_verbs"] = {}
      if self._type_grammar.endswith("simple_trans"):
        dataset_representation["intransitive_verbs"] = {}
      if not (self._type_grammar.endswith("adverb") or
              self._type_grammar == "conjunction"):
        dataset_representation["adverbs"] = {}
      if self._exclude_type_grammar:
        dataset_representation.update(
            {"exclude_grammar": self._exclude_grammar.__str__()})
      json.dump(dataset_representation, outfile, indent=4)
    logging.info("Saved dataset to %s", output_path)
    return output_path
Saves the current generated data to a file.
language/gscan/data/dataset.py