class_docstr: Pipeline for text-to-image generation using Stable Diffusion and Attend-and-Excite.
  
  This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
  implemented for all pipelines (downloading, saving, running on a particular device, etc.).
  
  Args:
      vae ([`AutoencoderKL`]):
          Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.
      text_encoder ([`~transformers.CLIPTextModel`]):
          Frozen text-encoder ([clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14)).
      tokenizer ([`~transformers.CLIPTokenizer`]):
          A `CLIPTokenizer` to tokenize text.
      unet ([`UNet2DConditionModel`]):
          A `UNet2DConditionModel` to denoise the encoded image latents.
      scheduler ([`SchedulerMixin`]):
          A scheduler to be used in combination with `unet` to denoise the encoded image latents. Can be one of
          [`DDIMScheduler`], [`LMSDiscreteScheduler`], or [`PNDMScheduler`].
      safety_checker ([`StableDiffusionSafetyChecker`]):
          Classification module that estimates whether generated images could be considered offensive or harmful.
          Please refer to the [model card](https://huggingface.co/runwayml/stable-diffusion-v1-5) for more details
          about a model's potential harms.
      feature_extractor ([`~transformers.CLIPImageProcessor`]):
          A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
docstr: Computes the maximum attention value for each of the tokens we wish to alter.
docstr_tok: ["Computes","the","maximum","attention","value","for","each","of","the","tokens","we","wish","to","alter","."]
code: def _compute_max_attention_per_index(
      attention_maps: torch.Tensor,
      indices: List[int],
  ) -> List[torch.Tensor]:
      """Computes the maximum attention value for each of the tokens we wish to alter."""
      attention_for_text = attention_maps[:, :, 1:-1]
      attention_for_text *= 100
      attention_for_text = torch.nn.functional.softmax(
          attention_for_text, dim=-1
      )
  
      # Shift indices since we removed the first token
      indices = [index - 1 for index in indices]
  
      # Extract the maximum values
      max_indices_list = []
      for i in indices:
          image = attention_for_text[:, :, i]
          smoothing = GaussianSmoothing().to(attention_maps.device)
          input = F.pad(
              image.unsqueeze(0).unsqueeze(0),
              (1, 1, 1, 1),
              mode="reflect",
          )
          image = smoothing(input).squeeze(0).squeeze(0)
          max_indices_list.append(image.max())
      return max_indices_list
  
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 .None import StableDiffusionPipelineOutput
  from .safety_checker import StableDiffusionSafetyChecker
label_desc: Use image node_id 11 for calling the StableDiffusionAttendAndExcitePipeline obj's underlying member method code with example usage: obj._compute_max_attention_per_index(attention_maps, indices) and returns: max_indices_list