class_docstr: DatasetBuilder for bot_adversarial_dialogue dataset.
class_docstr_tok: ["DatasetBuilder","for","bot_adversarial_dialogue","dataset","."]
docstr: Yields examples.
docstr_tok: ["Yields","examples","."]
code: def _generate_examples(self, path, split_name=str):
      """Yields examples."""
  
      def _preprocess_row(row: str) -> str:
          """Preprocesses a dataset row using ParlAI format.
  
          This function is based on:
          https://github.com/facebookresearch/ParlAI/blob/9974b947fb2e801dc5608f495828532c2a714742/parlai/utils/misc.py#L639
  
          Args:
            row: An unprocessed row from the bot_adversarial_dialogue dataset.
  
          Returns:
            A processed row, in which special characters are properly formatted.
          """
          row = str(row)
          row = row.replace("\\t", "\t")
          row = row.replace("\\n", "\n")
          row = row.replace("__PIPE__", "|")
          return row
  
      def _get_row_features(row: str) -> Mapping[str, Any]:
          """Extracts dialogue features from a dataset row."""
          row_features = {}
          for field in row.split("\t"):
              key, value = field.split(":", maxsplit=1)
              row_features[key] = value
          return row_features
  
      # Indices to keep track of the dialogue turns as the conversation unfolds.
      previous_conversation_round = 0
      dialogue_id = 0
  
      with epath.Path(path).open() as f:
          for i, row in enumerate(f):
              example_id = f"{split_name}_{i}"
              cleaned_row = _preprocess_row(row)
              row_features = _get_row_features(cleaned_row)
  
              example = {
                  "id": row_features.get("id", example_id),
                  "labels": row_features["labels"],
                  "episode_done": bool_utils.parse_bool(
                      row_features["episode_done"]
                  ),
              }
  
              if self.builder_config.name == "dialogue_datasets":
                  conversation_acts = row_features["text"].split("\n")
                  conversation_len = len(conversation_acts)
  
                  if conversation_len < previous_conversation_round:
                      previous_conversation_round = 0
                      dialogue_id += 1
                  else:
                      previous_conversation_round += 1
  
                  # Remove the "your persona: ..." prefix from the bot persona
                  # specifications.
                  bot_persona = [
                      str_.strip().split(": ", 1)[-1]
                      for str_ in row_features["bot_persona"]
                      .strip()
                      .split("\n")
                  ]
  
                  example.update(
                      {
                          "round_id": conversation_len - 1,
                          "dialogue_id": dialogue_id,
                          "text": conversation_acts[-1],
                          "bot_persona": bot_persona,
                          "speaker_to_eval": row_features[
                              "speaker_to_eval"
                          ],
                      }
                  )
  
              else:
                  example["text"] = row_features["text"]
  
              yield example_id, example
  
file_path: datasets/tensorflow_datasets/datasets/bot_adversarial_dialogue/bot_adversarial_dialogue_dataset_builder.py
imports: import os
  from typing import Any, Mapping
  from etils import epath
  import numpy
  from tensorflow_datasets.core.utils import bool_utils
  import tensorflow_datasets.public_api
label_desc: Use image node_id 3 for calling the Builder obj's underlying member method code with example usage: obj._generate_examples(path, split_name) and returns: row, row_features