code: def activations_dict_to_array(activations_dict):
      """
      Converts the dict used to collect activations into an array of the
      shape (batch, layers, neurons, token position).
      Args:
          activations_dict: python dictionary. Contains a key/value for each layer
          in the model whose activations were collected. Key is the layer id ('0', '1').
          Value is a tensor of shape (batch, position, neurons).
      """
  
      activations = []
      for i in sorted(activations_dict.keys()):
          activations.append(activations_dict[i])
  
      activations = np.array(activations)
      # 'activations' now is in the shape (layer, batch, position, neurons)
  
      activations = np.swapaxes(activations, 2, 3)
      activations = np.swapaxes(activations, 0, 1)
      # print('after swapping: ', activations.shape)
      return activations
  
imports: from collections import defaultdict
  import inspect
  import json
  import os
  import random
  import torch
  import transformers
  from transformers import BatchEncoding
  import ecco
  import numpy
  from IPython import display
  from torch.nn import functional
  from ecco.attribution import compute_primary_attributions_scores
  from ecco.output import OutputSeq
  from typing import Optional, Any, List, Tuple, Dict, Union
  from operator import attrgetter
  import re
  from ecco.util import is_partial_token, strip_tokenizer_prefix
  from packaging import version
label_desc: Use image node_id 4 for calling a global function with example usage: activations_dict_to_array(activations_dict) and returns: activations