docstr: Get summary plot matrix for a WSC-SPECIFIC summary options and example indices.
docstr_tok: ["Get","summary","plot","matrix","for","a","WSC-SPECIFIC","summary","options","and","example","indices","."]
code: def get_specific_head_matrix(
      self, head_matrix_option: str, example_ids: List[int]
  ) -> np.array:
      """Get summary plot matrix for a WSC-SPECIFIC summary options and example indices."""
      z = None
      for model_id, model_name in zip(self.model_ids, self.model_names):
          selected_attentions_spans = [
              np.stack(
                  self.map_model_to_collateral[model_id][index][
                      "attention_spans"
                  ]
              )
              for index in example_ids
          ]  # to collect multiple attention matrices (from different examples)
  
          if (
              head_matrix_option
              == f"{model_name}_coreference_intensity"
          ):
              z = np.mean(
                  [
                      attn.max(axis=(2, 3))
                      for attn in selected_attentions_spans
                  ],
                  axis=0,
              )  # when more than 1 token in span> select max of them
  
          elif (
              head_matrix_option
              == f"{model_name}_accuracy_based_on_head"
          ):
              z = self.map_model_to_collateral[model_id][
                  example_ids[0]
              ]["acc_matrix"]
  
          if self.mode == "compare":
              selected_attentions_spans1 = [
                  np.stack(
                      self.map_model_to_collateral["model1"][index][
                          "attention_spans"
                      ]
                  )
                  for index in example_ids
              ]  # to collect multiple attention matrices (from different examples)
              selected_attentions_spans2 = [
                  np.stack(
                      self.map_model_to_collateral["model2"][index][
                          "attention_spans"
                      ]
                  )
                  for index in example_ids
              ]  # to collect multiple attention matrices (from different examples)
              if head_matrix_option == "coreference_intensity_delta":
                  span_weights_delta = [
                      attentions_spans2.max(axis=(2, 3))
                      - attentions_spans1.max(axis=(2, 3))
                      for (attentions_spans1, attentions_spans2) in zip(
                          selected_attentions_spans1,
                          selected_attentions_spans2,
                      )
                  ]
                  z = np.mean(span_weights_delta, axis=0)
      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 8 for calling the WSCTask obj's underlying member method code with example usage: obj.get_specific_head_matrix(head_matrix_option, example_ids) and returns: z