class_docstr: Attention processor for IP-Adapater for PyTorch 2.0.
  Args:
      hidden_size (`int`):
          The hidden size of the attention layer.
      cross_attention_dim (`int`):
          The number of channels in the `encoder_hidden_states`.
      rank (`int`, defaults to 4):
          The dimension of the LoRA update matrices.
      network_alpha (`int`, *optional*):
          Equivalent to `alpha` but it's usage is specific to Kohya (A1111) style LoRAs.
      lora_scale (`float`, defaults to 1.0):
          the weight scale of LoRA.
      scale (`float`, defaults to 1.0):
          the weight scale of image prompt.
      num_tokens (`int`, defaults to 4 when do ip_adapter_plus it should be 16):
          The context length of the image features.
class_docstr_tok: ["Attention","processor","for","IP-Adapater","for","PyTorch","2.0",".","Args",":","hidden_size","(","`","int","`",")",":","The","hidden","size","of","the","attention","layer",".","cross_attention_dim","(","`","int","`",")",":","The","number","of","channels","in","the","`","encoder_hidden_states","`",".","rank","(","`","int","`",",","defaults","to","4",")",":","The","dimension","of","the","LoRA","update","matrices",".","network_alpha","(","`","int","`",",","*","optional","*",")",":","Equivalent","to","`","alpha","`","but","it","'s","usage","is","specific","to","Kohya","(","A1111",")","style","LoRAs",".","lora_scale","(","`","float","`",",","defaults","to","1.0",")",":","the","weight","scale","of","LoRA",".","scale","(","`","float","`",",","defaults","to","1.0",")",":","the","weight","scale","of","image","prompt",".","num_tokens","(","`","int","`",",","defaults","to","4","when","do","ip_adapter_plus","it","should","be","16",")",":","The","context","length","of","the","image","features","."]
code: def __init__(
      self,
      hidden_size,
      cross_attention_dim=None,
      rank=4,
      network_alpha=None,
      lora_scale=1.0,
      scale=1.0,
      num_tokens=4,
  ):
      super().__init__()
  
      self.rank = rank
      self.lora_scale = lora_scale
  
      self.to_q_lora = LoRALinearLayer(
          hidden_size, hidden_size, rank, network_alpha
      )
      self.to_k_lora = LoRALinearLayer(
          cross_attention_dim or hidden_size,
          hidden_size,
          rank,
          network_alpha,
      )
      self.to_v_lora = LoRALinearLayer(
          cross_attention_dim or hidden_size,
          hidden_size,
          rank,
          network_alpha,
      )
      self.to_out_lora = LoRALinearLayer(
          hidden_size, hidden_size, rank, network_alpha
      )
  
      self.hidden_size = hidden_size
      self.cross_attention_dim = cross_attention_dim
      self.scale = scale
      self.num_tokens = num_tokens
  
      self.to_k_ip = nn.Linear(
          cross_attention_dim or hidden_size, hidden_size, bias=False
      )
      self.to_v_ip = nn.Linear(
          cross_attention_dim or hidden_size, hidden_size, bias=False
      )
  
imports: import inspect
  from typing import Any, Callable, Dict, List, Optional, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from packaging import version
  from safetensors import safe_open
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection
  from diffusers.configuration_utils import FrozenDict
  from diffusers.image_processor import VaeImageProcessor
  from diffusers.loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
  from diffusers.models.attention_processor import FusedAttnProcessor2_0
  from diffusers.models.lora import LoRALinearLayer, adjust_lora_scale_text_encoder
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline
  from diffusers.pipelines.stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
  from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
  from diffusers.schedulers import KarrasDiffusionSchedulers
  from diffusers.utils import USE_PEFT_BACKEND, _get_model_file, deprecate, logging, scale_lora_layers, unscale_lora_layers
  from diffusers.utils.torch_utils import randn_tensor
label_desc: Use image node_id 1 to create a new LoRAIPAdapterAttnProcessor2_0 object from inherited base classes: nn with example: obj = LoRAIPAdapterAttnProcessor2_0(hidden_size, cross_attention_dim, rank, network_alpha, lora_scale, scale, num_tokens)