class_docstr: A vanilla Transformer Encoder block
class_docstr_tok: ["A","vanilla","Transformer","Encoder","block"]
code: def forward(
      self,
      x: torch.Tensor,
      att_mask: Optional[Union[torch.Tensor, AttentionMask]] = None,
      input_mask: Optional[torch.Tensor] = None,
  ):
      if self.patch_emb is not None:
          x = self.patch_emb(x)
  
      if self.pose_encoding is not None:
          x = self.pose_encoding(x)
  
          if hasattr(self, "embedding_projector"):
              x = self.embedding_projector(x)
  
      # Handle the optional input masking, differs on Q, K, V
      if input_mask is not None:
          q = x
          k = x * input_mask.unsqueeze(-1)
          v = k
      else:
          q, k, v = x, x, x
  
      # Pre/Post norms and residual paths are already handled
      x = self.wrap_att(inputs=[q, k, v], att_mask=att_mask)
      x = self.wrap_ff(inputs=[x])
  
      # Optional simplicial embeddings
      if self.simplicial_embedding is not None:
          x = self.simplicial_embedding(x)
  
      return x
  
imports: import logging
  from dataclasses import asdict
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn
  from xformers._deprecation_warning import deprecated_function
  from xformers.components import PatchEmbeddingConfig, PostNorm, PreNorm, Residual, ResidualNormStyle, build_multi_head_attention, build_patch_embedding
  from xformers.components.attention import AttentionMask
  from xformers.components.feedforward import build_feedforward
  from xformers.components.positional_embedding import build_positional_embedding
  from xformers.components.residual import get_deepnorm_coefficients
  from xformers.components.simplicial_embedding import SimplicialEmbedding
  from xformers.factory.block_configs import NormalizationType, xFormerDecoderConfig, xFormerEncoderConfig
label_desc: Use image node_id 4 for calling the xFormerEncoderBlock obj's underlying member method code with example usage: obj.forward(x, att_mask, input_mask) and returns: x