class_docstr: Stack of transformer blocks
class_docstr_tok: ["Stack","of","transformer","blocks"]
code: def __init__(
      self,
      seq_length: int,
      num_layers: int,
      num_heads: int,
      hidden_dim: int,
      mlp_expansion: int,
      dropout: float,
      is_decoder: bool = False,
      norm_layer: Callable[..., torch.nn.Module] = partial(
          nn.LayerNorm, eps=1e-6
      ),
  ) -> None:
      super().__init__()
      self.is_decoder = is_decoder
      self.dropout = nn.Dropout(dropout)
      self.layers = nn.ModuleList()
      # Stack num_layers transformer blocks:
      for i in range(num_layers):
          self.layers.add_module(
              f"encoder_layer_{i}",
              TransformerBlock(
                  seq_length=seq_length,
                  num_heads=num_heads,
                  hidden_dim=hidden_dim,
                  mlp_dim=mlp_expansion * hidden_dim,
                  drop_out_rate=dropout,
                  drop_path_rate=dropout,
                  norm_layer=norm_layer,
                  is_decoder=is_decoder,
              ),
          )
  
imports: from functools import partial
  from typing import Callable, Optional
  import torch
  import torch.nn
  from torch import Tensor
  from .layers_utils import MLP, StochasticDepth, WindowMultiHeadAttention
label_desc: Use image node_id 1 to create a new Transformer object from inherited base classes: nn with example: obj = Transformer(seq_length, num_layers, num_heads, hidden_dim, mlp_expansion, dropout, is_decoder, norm_layer)