class_docstr: Self-attention + MLP block. One full "layer".
class_docstr_tok: ["Self-attention","+","MLP","block",".","One","full","``","layer","''","."]
code: def __init__(
      self,
      attention_module,
      embed_dim,
      num_heads,
      mlp_ratio=4.0,
      mlp_dim=None,
      qkv_bias=False,
      qk_scale=None,
      dropout_rate=0.0,
      attention_dropout_rate=0.0,
      drop_path_rate=0.0,
      act_layer=nn.GELU,
      norm_layer=nn.LayerNorm,
      **kwargs,
  ):
      super().__init__()
      self.norm1 = norm_layer(embed_dim)
      self.attn = attention_module(
          embed_dim,
          num_heads=num_heads,
          qkv_bias=qkv_bias,
          qk_scale=qk_scale,
          proj_dropout_rate=dropout_rate,
          attention_dropout_rate=attention_dropout_rate,
          **kwargs,
      )
      if drop_path_rate > 0.0:
          self.drop_path = PathDropout(drop_path_rate)
      else:
          self.drop_path = nn.Identity()
      self.norm2 = norm_layer(embed_dim)
      if mlp_dim is None:
          mlp_dim = int(embed_dim * mlp_ratio)
      self.mlp = Mlp(
          in_dim=embed_dim,
          mlp_dim=mlp_dim,
          act_layer=act_layer,
          dropout_rate=dropout_rate,
      )
  
imports: import copy
  import logging
  import math
  import torch
  import torch.nn
  from vissl.models.model_helpers import DropPath, to_2tuple, trunc_normal_
  from vissl.models.trunks import register_model_trunk
  from vissl.utils.hydra_config import AttrDict
label_desc: Use image node_id 1 to create a new AttentionBlock object from inherited base classes: nn with example: obj = AttentionBlock(attention_module, embed_dim, num_heads, mlp_ratio, mlp_dim, qkv_bias, qk_scale, dropout_rate, attention_dropout_rate, drop_path_rate, act_layer, norm_layer)