docstr: Aggregates the attention across the different layers and heads at the specified resolution.
code: def aggregate_attention(self, from_where: List[str]) -> torch.Tensor:
      """Aggregates the attention across the different layers and heads at the specified resolution."""
      out = []
      attention_maps = self.get_average_attention()
      for location in from_where:
          for item in attention_maps[location]:
              cross_maps = item.reshape(
                  -1, self.attn_res[0], self.attn_res[1], item.shape[-1]
              )
              out.append(cross_maps)
      out = torch.cat(out, dim=0)
      out = out.sum(0) / out.shape[0]
      return out
  
imports: import inspect
  import math
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torch.nn import functional
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
  from ...image_processor import VaeImageProcessor
  from ...loaders import LoraLoaderMixin, TextualInversionLoaderMixin
  from ...models import AutoencoderKL, UNet2DConditionModel
  from ...models.attention_processor import Attention
  from ...models.lora import adjust_lora_scale_text_encoder
  from ...schedulers import KarrasDiffusionSchedulers
  from ...utils import USE_PEFT_BACKEND, deprecate, logging, replace_example_docstring, scale_lora_layers, unscale_lora_layers
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import DiffusionPipeline
  from ..stable_diffusion import StableDiffusionPipelineOutput
  from ..stable_diffusion.safety_checker import StableDiffusionSafetyChecker
label_desc: Use image node_id 5 for calling the AttentionStore obj's underlying member method code with example usage: obj.aggregate_attention(from_where) and returns: out