class_docstr: Adapted from CLIP: https://github.com/openai/CLIP/blob/main/clip/model.py
class_docstr_tok: ["Adapted","from","CLIP",":","https",":","\/\/github.com\/openai\/CLIP\/blob\/main\/clip\/model.py"]
code: def __init__(
      self,
      spacial_dim: int,
      embed_dim: int,
      num_heads_channels: int,
      output_dim: int = None,
  ):
      super().__init__()
      self.positional_embedding = nn.Parameter(
          th.randn(embed_dim, spacial_dim**2 + 1) / embed_dim**0.5
      )
      self.qkv_proj = conv_nd(1, embed_dim, 3 * embed_dim, 1)
      self.c_proj = conv_nd(1, embed_dim, output_dim or embed_dim, 1)
      self.num_heads = embed_dim // num_heads_channels
      self.attention = QKVAttention(self.num_heads)
  
imports: from abc import abstractmethod
  import math
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from ldm.modules.diffusionmodules.util import checkpoint, conv_nd, linear, avg_pool_nd, zero_module, normalization, timestep_embedding
  from ldm.modules.attention import SpatialTransformer
  from ldm.util import exists
label_desc: Use image node_id 1 to create a new AttentionPool2d object from inherited base classes: nn with example: obj = AttentionPool2d(spacial_dim, embed_dim, num_heads_channels, output_dim)