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","."]
code: def __init__(
      self,
      task_run: "TaskRun",
      args: "DictConfig",
      shared_state: "SharedTaskState",
  ):
      super().__init__(task_run, args=args, shared_state=shared_state)
      random.seed(self.args.blueprint.random_seed)
      np.random.seed(self.args.blueprint.random_seed)
      self.subtasks_per_unit = self.args.blueprint.subtasks_per_unit
      self.conversation_count = self.args.blueprint.conversation_count
      self.annotation_last_only = (
          self.args.blueprint.annotation_last_only
      )
  
      if self.subtasks_per_unit <= 0:
          raise Exception(
              f"subtasks_per_unit must be greater than zero but was {self.subtasks_per_unit}"
          )
  
      self.raw_data = self._initialization_data_dicts
  
      # Load from file if needed specifying which utterances within each
      # conversation to annotate
      self.annotation_indices = None
      if self.args.blueprint.annotation_indices_jsonl:
          if self.annotation_last_only:
              raise RuntimeError(
                  "Cannot use flag annotation_last_only and supply a file with annotation indices."
              )
          self.annotation_indices = []
          with open(
              self.args.blueprint.annotation_indices_jsonl,
              "r",
              encoding="utf-8-sig",
          ) as f:
              line = f.readline()
              while line:
                  conversation_indices = json.loads(line)
                  self.annotation_indices.append(conversation_indices)
                  line = f.readline()
          if len(self.annotation_indices) != len(self.raw_data):
              raise Exception(
                  f"Cannot specify a different length of annotation indices "
                  f"({len(self.annotation_indices)}) than conversations ({len(self.raw_data)})."
              )
          # TODO: should check that utterances specified are all bot
          # utterances (agent_idx == 1)
  
      if self.conversation_count:
          self.raw_data = self.raw_data[: self.conversation_count]
          if self.annotation_indices:
              self.annotation_indices = self.annotation_indices[
                  : self.conversation_count
              ]
  
      # Reorganize the self-chat data
      self._initialization_data_dicts = self.process_data(
          self.raw_data, annotation_indices=self.annotation_indices
      )
  
      # Now chunk the data into groups of <num_subtasks>
      grouped_data = []
      logging.info(
          f"Raw data length: {len(self.raw_data)}. self.subtasks_per_unit: {self.subtasks_per_unit}"
      )
      for i in range(
          0,
          len(self._initialization_data_dicts),
          self.subtasks_per_unit,
      ):
          chunk = self._initialization_data_dicts[
              i : i + self.subtasks_per_unit
          ]
          grouped_data.append(chunk)
      self._initialization_data_dicts = grouped_data  # type: ignore
      # Last group may have less unless an exact multiple
      logging.info(
          f"Grouped data into {len(self._initialization_data_dicts)} tasks with {self.subtasks_per_unit} subtasks each."
      )
  
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 1 to create a new TurnAnnotationsStaticBlueprint object from inherited base classes: StaticReactBlueprint with example: obj = TurnAnnotationsStaticBlueprint(task_run, args, shared_state)