docstr: Sets the attention processor to use to compute attention.
  
  Parameters:
      processor (`dict` of `AttentionProcessor` or only `AttentionProcessor`):
          The instantiated processor class or a dictionary of processor classes that will be set as the processor
          for **all** `Attention` layers.
  
          If `processor` is a dict, the key needs to define the path to the corresponding cross attention
          processor. This is strongly recommended when setting trainable attention processors.
code: def set_attn_processor(
      self,
      processor: Union[
          AttentionProcessor, Dict[str, AttentionProcessor]
      ],
  ):
      r"""
      Sets the attention processor to use to compute attention.
  
      Parameters:
          processor (`dict` of `AttentionProcessor` or only `AttentionProcessor`):
              The instantiated processor class or a dictionary of processor classes that will be set as the processor
              for **all** `Attention` layers.
  
              If `processor` is a dict, the key needs to define the path to the corresponding cross attention
              processor. This is strongly recommended when setting trainable attention processors.
  
      """
      count = len(self.attn_processors.keys())
  
      if isinstance(processor, dict) and len(processor) != count:
          raise ValueError(
              f"A dict of processors was passed, but the number of processors {len(processor)} does not match the"
              f" number of attention layers: {count}. Please make sure to pass {count} processor classes."
          )
  
      def fn_recursive_attn_processor(
          name: str, module: torch.nn.Module, processor
      ):
          if hasattr(module, "set_processor"):
              if not isinstance(processor, dict):
                  module.set_processor(processor)
              else:
                  module.set_processor(
                      processor.pop(f"{name}.processor")
                  )
  
          for sub_name, child in module.named_children():
              fn_recursive_attn_processor(
                  f"{name}.{sub_name}", child, processor
              )
  
      for name, module in self.named_children():
          fn_recursive_attn_processor(name, module, processor)
  
imports: from typing import Dict, Union
  import torch
  import torch.nn.functional
  from torch import nn
  from torch.utils.checkpoint import checkpoint
  from ..configuration_utils import ConfigMixin, register_to_config
  from ..loaders import PeftAdapterMixin
  from .attention import BasicTransformerBlock, SkipFFTransformerBlock
  from .attention_processor import ADDED_KV_ATTENTION_PROCESSORS, CROSS_ATTENTION_PROCESSORS, AttentionProcessor, AttnAddedKVProcessor, AttnProcessor
  from .embeddings import TimestepEmbedding, get_timestep_embedding
  from .modeling_utils import ModelMixin
  from .normalization import GlobalResponseNorm, RMSNorm
  from .resnet import Downsample2D, Upsample2D
label_desc: Use image node_id 5 for calling the UVit2DModel obj's underlying member method code with example usage: obj.set_attn_processor(processor) without return types