class_docstr: TransformerEncoderLayer class.
  Args:
      d_model (int): dimension of model
      nhead (int): number of head
      dim_feedforward (int): dimension of feedforward
      dropout (float): dropout
      activation (str): activation
class_docstr_tok: ["TransformerEncoderLayer","class",".","Args",":","d_model","(","int",")",":","dimension","of","model","nhead","(","int",")",":","number","of","head","dim_feedforward","(","int",")",":","dimension","of","feedforward","dropout","(","float",")",":","dropout","activation","(","str",")",":","activation"]
code: def __init__(
      self,
      d_model,
      nhead,
      dim_feedforward=2048,
      dropout=0.15,
      activation="relu",
  ):
      super().__init__()
      self.self_attn = nn.MultiheadAttention(
          d_model, nhead, dropout=dropout
      )
      # Implementation of Feedforward model
      self.linear1 = nn.Linear(d_model, dim_feedforward)
      self.dropout = nn.Dropout(dropout)
      self.linear2 = nn.Linear(dim_feedforward, d_model)
  
      self.norm1 = nn.LayerNorm(d_model)
      self.norm2 = nn.LayerNorm(d_model)
      self.dropout1 = nn.Dropout(dropout)
      self.dropout2 = nn.Dropout(dropout)
  
      self.activation = _get_activation_fn(activation)
  
imports: import copy
  import torch
  import torch.nn.functional
  from typing import Optional
  from torch import nn, Tensor
label_desc: Use image node_id 1 to create a new TransformerEncoderLayer object from inherited base classes: nn with example: obj = TransformerEncoderLayer(d_model, nhead, dim_feedforward, dropout, activation)