class_docstr: HellaSwag Dataset.
class_docstr_tok: ["HellaSwag","Dataset","."]
docstr: Yields examples.
docstr_tok: ["Yields","examples","."]
code: def _generate_examples(self, filepath, domain=None, source=None):
      """Yields examples."""
      with epath.Path(filepath).open() as f:
          for idx, line in enumerate(f):
              elem = json.loads(line)
              elem_id = "%s_%d" % (os.path.basename(filepath), idx)
  
              if domain == "IND" and elem["split_type"] != "indomain":
                  continue
              if domain == "OOD" and elem["split_type"] != "zeroshot":
                  continue
              if source and not elem["source_id"].startswith(source):
                  continue
  
              yield elem_id, {
                  "context": elem["ctx"],
                  "endings": elem["endings"],
                  "activity_label": elem["activity_label"],
                  "label": elem.get("label", -1),
                  "split_type": elem["split_type"],
                  "source_id": elem["source_id"],
              }
  
file_path: datasets/tensorflow_datasets/text/hellaswag.py
imports: from __future__ import annotations
  import json
  import os
  from etils import epath
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 3 for calling the Hellaswag obj's underlying member method code with example usage: obj._generate_examples(filepath, domain, source) without return types