class_docstr: Analyzer.
  
  Given a run_id, we can do lots of fun things!
class_docstr_tok: ["Analyzer",".","Given","a","run_id",",","we","can","do","lots","of","fun","things","!"]
docstr: Extract response data from task data.
  
  :param unit_details:
      full extracted data from a unit
  :param idx:
      index of the singular evaluation within unit_details to extract
  
  :return response:
      Formatted worker's response data from the task
docstr_tok: ["Extract","response","data","from","task","data",".",":","param","unit_details",":","full","extracted","data","from","a","unit",":","param","idx",":","index","of","the","singular","evaluation","within","unit_details","to","extract",":","return","response",":","Formatted","worker","'s","response","data","from","the","task"]
code: def _extract_response_by_index(
      self, unit_details: Dict[str, Any], idx: int
  ) -> Optional[Dict[str, Any]]:
      """
      Extract response data from task data.
  
      :param unit_details:
          full extracted data from a unit
      :param idx:
          index of the singular evaluation within unit_details to extract
  
      :return response:
          Formatted worker's response data from the task
      """
      task_data = unit_details["data"][idx]
      response: Dict[str, Any] = {
          "run_id": self.run_id,
          "worker": unit_details["worker_id"],
          "worker_name": Worker.get(
              self.mephisto_db, unit_details["worker_id"]
          ).worker_name,
          "time_taken": unit_details["task_end"]
          - unit_details["task_start"],
          "question": task_data["task_specs"]["question"],
          "unit_id": unit_details["unit_id"],
          "task_start": unit_details["task_start"],
      }
      onboarding = task_data["task_specs"].get("is_onboarding", False)
      if (
          "speakerChoice" not in task_data
          or task_data["speakerChoice"] == ""
      ):
          print("speakerChoice not in task data!")
          return
      choice = task_data["speakerChoice"]
      if onboarding:
          response["correct"] = (
              choice == task_data["pairing_dict"]["correct_answer"]
          )
      else:
          response["correct"] = -1
  
      speakers_to_eval = sorted(
          task_data["pairing_dict"]["speakers_to_eval"]
      )
      response.update(
          {
              "winner": choice,
              "loser": speakers_to_eval[
                  1 - (speakers_to_eval.index(choice))
              ],
              "eval_choice_0": speakers_to_eval[0],
              "eval_choice_1": speakers_to_eval[1],
              "reason": task_data["textReason"],
              "is_onboarding": onboarding,
              "matchup": f"{'__vs__'.join(speakers_to_eval)}",
              "pairing_id": task_data["pair_id"],
          }
      )
  
      # If it exists, add in which checkboxes of possible reasons the Turkers checked
      if len(task_data.get("speakerReasons", {})) > 0:
          response.update(
              {
                  self.checkbox_prefix + reason: checked
                  for reason, checked in task_data[
                      "speakerReasons"
                  ].items()
              }
          )
      return response
  
imports: import hashlib
  import json
  import os
  from copy import deepcopy
  from datetime import datetime
  from typing import Dict, Any, List, Optional
  import numpy
  import pandas
  from IPython.core.display import HTML
  from mephisto.tools.data_browser import DataBrowser
  from mephisto.abstractions.databases.local_database import LocalMephistoDB
  from mephisto.data_model.unit import Unit
  from mephisto.data_model.worker import Worker
  from scipy.stats import binom_test
  from parlai.core.params import ParlaiParser
  from parlai.crowdsourcing.tasks.acute_eval.acute_eval_blueprint import BLUEPRINT_TYPE
  from parlai.crowdsourcing.tasks.acute_eval.fast_acute_blueprint import FAST_ACUTE_BLUEPRINT_TYPE
  from parlai.crowdsourcing.tasks.acute_eval.util import get_hashed_combo_path
label_desc: Use image node_id 2 for calling the AcuteAnalyzer obj's underlying member method code with example usage: obj._extract_response_by_index(unit_details, idx) and returns: response