class_docstr: Abstract class for defining tasks.
  
  To create your own task, please refer to the provided ABSATask and WSCTask as examples for how to do so.
  There are 4 abstract methods that must be defined: _init_tsne_layout(), _init_table_cols_layout(),
  get_val_to_label_map(), get_tsne_rows(). These definitions will all depend on how the input dataframe
  is structured.
  
  Attributes:
      mode: 'normal' if a single model is loaded, else 'compare'
      num_layers: number of transformer layers in the model
      model_ids: ["model1"] or ["model1", "model2"], used internally
      model_names: a list of the given model names to be displayed in app (correspond to above model_ids)
      collateral_paths: list of filepaths to the model collaterals (attn, hidden_states)
      df_paths: list of filepaths to model dataframe (everything else)
  
      tsne_internal_options: list of column names from the dataframe to color the tsne plot with
      tsne_displayed_options: list of names to display corresponding to the above plot options
      tsne_plot_description: string title for the tsne plot
      attn_map_options: list of options to display for attention map plot
      head_matrix_options: list of options to display for head matrix plot
      table_cols: list of columns to display for the summary table
  
      map_model_id_to_name: dictionary mapping "model1"/"model2" (used internally) to map_model_to_path
      map_model_to_full_df:dict mapping model_ids to dataframes (after _preprocess_df)
      map_model_to_df: dict mapping model_ids to dataframes (after _preprocess_df and _process_all_df)
      map_model_to_collateral: dict mapping model_ids to collateral pahts
docstr: Get summary plot matrix for a task-AGNOSTIC summary option and example indices.
docstr_tok: ["Get","summary","plot","matrix","for","a","task-AGNOSTIC","summary","option","and","example","indices","."]
code: def get_head_matrix(
      self, head_matrix_option: str, example_ids: List[int]
  ) -> np.array:
      """Get summary plot matrix for a task-AGNOSTIC summary option and example indices."""
      z = None
      attentions_dict = {}
  
      # Compute std(attn) if given the corresponding option
      for model_id, model_name in zip(self.model_ids, self.model_names):
          if head_matrix_option == f"{model_name}_std":
              attns = [
                  np.stack(
                      self.map_model_to_collateral[model_id][
                          example_id
                      ]["attentions"]
                  )
                  for example_id in example_ids
              ]
              attentions_dict[model_id] = attns
              z = np.mean(
                  [attn.std(axis=(2, 3)) for attn in attns], axis=0
              )
  
      # Compute std(attn2 - attn1) if given the corresponding option
      if self.mode == "compare":
          if head_matrix_option == "delta_std":
              attns1 = attentions_dict["model1"]
              attns2 = attentions_dict["model2"]
              attns_delta = [
                  attn2 - attn1
                  for (attn1, attn2) in zip(attns1, attns2)
              ]
              z = np.mean(
                  [attn.std(axis=(2, 3)) for attn in attns_delta],
                  axis=0,
              )
  
      # If head_matrix_option not task-agnostic
      if z is None:
          z = self.get_specific_head_matrix(
              head_matrix_option, example_ids
          )
  
      assert z is not None, "z is None"
  
      return z
  
imports: from typing import List, Tuple, Dict, Union
  from abc import ABC, abstractmethod
  import torch
  import pandas
  import numpy
label_desc: Use image node_id 16 for calling the Task obj's underlying member method code with example usage: obj.get_head_matrix(head_matrix_option, example_ids) and returns: z