class_docstr: standard transformer encoder
  
  Example:
      >>> import torch
      >>> from towhee.models.layers.transformer_encoder import TransformerEncoder
      >>>
      >>> dummpy_x = torch.rand(2, 4)
      >>> mode = TransformerEncoder(d_model=4, n_head=1, dim_ff=1, dropout=0.0, num_layers=1, num_frames=2)
      >>> out = mode(dummy_x)
      >>> print(out.shape)
      torch.Size([2, 2, 4])
class_docstr_tok: ["standard","transformer","encoder","Example",":",">",">",">","import","torch",">",">",">","from","towhee.models.layers.transformer_encoder","import","TransformerEncoder",">",">",">",">",">",">","dummpy_x","=","torch.rand","(","2",",","4",")",">",">",">","mode","=","TransformerEncoder","(","d_model=4",",","n_head=1",",","dim_ff=1",",","dropout=0.0",",","num_layers=1",",","num_frames=2",")",">",">",">","out","=","mode","(","dummy_x",")",">",">",">","print","(","out.shape",")","torch.Size","(","[","2",",","2",",","4","]",")"]
code: def __init__(
      self,
      d_model,
      n_head,
      dim_ff,
      dropout=0.0,
      num_layers=1,
      num_frames=64,
  ):
      super().__init__()
      self.pos_embed = PositionEmbedding(
          d_model=d_model, max_len=num_frames, dropout=dropout
      )
  
      encoder = nn.TransformerEncoderLayer(
          d_model=d_model,
          nhead=n_head,
          dim_feedforward=dim_ff,
          dropout=dropout,
          activation="relu",
      )
      norm_layer = nn.LayerNorm(d_model)
      self.transformer_encoder = nn.TransformerEncoder(
          encoder, num_layers, norm_layer
      )
  
imports: from torch import nn
  from towhee.models.layers.position_encoding import PositionEmbedding
label_desc: Use image node_id 1 to create a new TransformerEncoder object from inherited base classes: nn with example: obj = TransformerEncoder(d_model, n_head, dim_ff, dropout, num_layers, num_frames)