class_docstr: This Blueprint mixes in a live onboarding as the last subtask (in addition to an
  onboarding at the start), and actually increases the number of subtasks per unit by
  1.
class_docstr_tok: ["This","Blueprint","mixes","in","a","live","onboarding","as","the","last","subtask","(","in","addition","to","an","onboarding","at","the","start",")",",","and","actually","increases","the","number","of","subtasks","per","unit","by","1","."]
code: def __init__(
      self,
      task_run: "TaskRun",
      args: "DictConfig",
      shared_state: "SharedTaskState",
  ):
      super().__init__(task_run, args=args, shared_state=shared_state)
  
      raw_qc_convos = []
      with open(
          self.args.blueprint.onboarding_in_flight_data, "r"
      ) as f:
          line = f.readline()
          while line:
              qc_convo = json.loads(line)
              raw_qc_convos.append(qc_convo)
              line = f.readline()
      # Annotate all the utterances in the quality controls
      # So annotation_indices=None here
      self.quality_control_convos = self.process_data(
          raw_qc_convos, annotation_indices=None
      )
  
      # Re-chunk the data to add a quality control convo as the last subtask
      # No shuffling of the data for reproducibility's sake
      # (quality control will always be last subtask)
      # TODO: I don't think we need to re-chunk this actually; just iterate
      # over the data and add the quality control task
      all_data: List[Any] = []
      for grp in self._initialization_data_dicts:
          all_data.extend(grp)
  
      grouped_data = []
      number_of_tasks = math.floor(
          len(all_data) / self.subtasks_per_unit
      )
      for i in range(0, number_of_tasks):
          data_index = i * self.subtasks_per_unit
          chunk = all_data[
              data_index : data_index + self.subtasks_per_unit
          ]
          qc_convo_idx = i % len(self.quality_control_convos)
          chunk.append(self.quality_control_convos[qc_convo_idx])
          grouped_data.append(chunk)
  
      self._initialization_data_dicts = grouped_data
      self.subtasks_per_unit = len(chunk)
  
      print(
          f"{self.__class__.__name__}: Grouped data into {len(self._initialization_data_dicts)}"
          f"tasks with {self.subtasks_per_unit} subtasks each (added in-flight qualification task)."
      )
  
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 TurnAnnotationsStaticInFlightQABlueprint object from inherited base classes: TurnAnnotationsStaticBlueprint with example: obj = TurnAnnotationsStaticInFlightQABlueprint(task_run, args, shared_state)