class_docstr: This Blueprint has a subtasks number option to combine multiple conversations into
  "sub-HITs".
  
  It also has options for the onboarding data answers and the annotation bucket
  definitions.
class_docstr_tok: ["This","Blueprint","has","a","subtasks","number","option","to","combine","multiple","conversations","into","''","sub-HITs","''",".","It","also","has","options","for","the","onboarding","data","answers","and","the","annotation","bucket","definitions","."]
docstr: Helper function for processing conversations.
  
  :param annotation_indices:
      Array of turn indices to annotate of the
      actual conversation not including the context [So 0 is the "Hi!" if
      that's the first non-context utterance of the conversation.] If this is not
      specified, annotate all bot turns.
  :return: modified dialogue object
docstr_tok: ["Helper","function","for","processing","conversations",".",":","param","annotation_indices",":","Array","of","turn","indices","to","annotate","of","the","actual","conversation","not","including","the","context","[","So","0","is","the","``","Hi","!","''","if","that","'s","the","first","non-context","utterance","of","the","conversation",".","]","If","this","is","not","specified",",","annotate","all","bot","turns",".",":","return",":","modified","dialogue","object"]
code: def _process_conversation(
      self, d, annotation_indices: Optional[List[int]] = None
  ):
      """
      Helper function for processing conversations.
  
      :param annotation_indices:
          Array of turn indices to annotate of the
          actual conversation not including the context [So 0 is the "Hi!" if
          that's the first non-context utterance of the conversation.] If this is not
          specified, annotate all bot turns.
      :return: modified dialogue object
      """
      new_dialogue = []
      if annotation_indices is not None:
          max_turn_to_show = max(annotation_indices)
      else:
          max_turn_to_show = None
      adjusted_turn_idx = 0
      for full_turn in d["dialog"]:
          if len(full_turn) != 2:
              print(
                  f"Warning! Skipping incomplete conversation! full_turn was: {full_turn}"
              )
              continue
          if (
              max_turn_to_show is not None
              and adjusted_turn_idx > max_turn_to_show
          ):
              logging.info(
                  f"Skipping {adjusted_turn_idx}th utterance, b/c max_turn_to_show was {max_turn_to_show}."
              )
              continue
          # If there is a persona, which is context as in the ConvAI2
          # task, we don't want to display the persona utterances
          # Persona strings have the format "your persona:"
          if "your persona:" not in full_turn[0]["text"]:
              do_annotate = False
              new_dialogue.append(
                  {
                      "text": full_turn[0]["text"],
                      "agent_idx": 0,
                      "do_annotate": do_annotate,
                      "other_metadata": full_turn[0].get(
                          "other_metadata"
                      ),
                  }
              )
              adjusted_turn_idx += 1
          if "your persona:" not in full_turn[1]["text"]:
              if annotation_indices:
                  do_annotate = adjusted_turn_idx in annotation_indices
              else:
                  do_annotate = True
                  # Default to annotating all bot utterances
              new_dialogue.append(
                  {
                      "text": full_turn[1]["text"],
                      "agent_idx": 1,
                      "do_annotate": do_annotate,
                      "other_metadata": full_turn[1].get(
                          "other_metadata"
                      ),
                  }
              )
              adjusted_turn_idx += 1
      if (
          max_turn_to_show is not None
          and adjusted_turn_idx < max_turn_to_show
      ):
          raise Exception(
              f"Conversation had {adjusted_turn_idx} but max_turn_to_show was {max_turn_to_show}"
          )
      assert any(nd["do_annotate"] for nd in new_dialogue), (
          f"Have to annotate at least one index in the conversation! But new_dialogue was: {new_dialogue},"
          f' raw dialogue was: {d["dialog"]}, annotation_indices was: {annotation_indices}, '
          f"length of dialogue was {len(new_dialogue)}, adjusted_turn_idx was: {adjusted_turn_idx}, "
          f"max_turn_to_show: {max_turn_to_show}"
      )
  
      return new_dialogue
  
imports: import json
  import logging
  import math
  import os
  import random
  from dataclasses import dataclass, field
  from typing import Any, Dict, List, Optional, Union, TYPE_CHECKING
  import numpy
  from mephisto.operations.registry import register_mephisto_abstraction
  from mephisto.abstractions.blueprint import SharedTaskState
  from mephisto.abstractions.blueprints.static_react_task.static_react_blueprint import StaticReactBlueprint, StaticReactBlueprintArgs
  from omegaconf import DictConfig
label_desc: Use image node_id 4 for calling the TurnAnnotationsStaticBlueprint obj's underlying member method code with example usage: obj._process_conversation(d, annotation_indices) and returns: new_dialogue