code: def __init__(
      self,
      dim,
      n_heads,
      d_head,
      dropout=0.0,
      context_dim=None,
      gated_ff=True,
      checkpoint=True,
      disable_self_attn=False,
  ):
      super().__init__()
      attn_mode = (
          "softmax-xformers" if XFORMERS_IS_AVAILBLE else "softmax"
      )
      assert attn_mode in self.ATTENTION_MODES
      attn_cls = self.ATTENTION_MODES[attn_mode]
      self.disable_self_attn = disable_self_attn
      self.attn1 = attn_cls(
          query_dim=dim,
          heads=n_heads,
          dim_head=d_head,
          dropout=dropout,
          context_dim=context_dim if self.disable_self_attn else None,
      )  # is a self-attention if not self.disable_self_attn
      self.ff = FeedForward(dim, dropout=dropout, glu=gated_ff)
      self.attn2 = attn_cls(
          query_dim=dim,
          context_dim=context_dim,
          heads=n_heads,
          dim_head=d_head,
          dropout=dropout,
      )  # is self-attn if context is none
      self.norm1 = nn.LayerNorm(dim)
      self.norm2 = nn.LayerNorm(dim)
      self.norm3 = nn.LayerNorm(dim)
      self.checkpoint = checkpoint
  
imports: from inspect import isfunction
  import math
  import torch
  import torch.nn.functional
  from torch import nn, einsum
  from einops import rearrange, repeat
  from typing import Optional, Any
  from ldm.modules.diffusionmodules.util import checkpoint
  import os
label_desc: Use image node_id 1 to create a new BasicTransformerBlock object from inherited base classes: nn with example: obj = BasicTransformerBlock(dim, n_heads, d_head, dropout, context_dim, gated_ff, checkpoint, disable__attn)