class_docstr: Wrapper for torch.nn.TransformerEncoder that handles masked inputs.
class_docstr_tok: ["Wrapper","for","torch.nn.TransformerEncoder","that","handles","masked","inputs","."]
docstr: Args:
      data (torch.Tensor): tensor with shape (batch_size, seq_len, feature_dim)
      mask (torch.Tensor): bool tensor with shape (batch_size, seq_len).
          Sequence elements that are False are invalid.
  
  Returns:
      Tensor with shape (batch_size, feature_dim)
docstr_tok: ["Args",":","data","(","torch.Tensor",")",":","tensor","with","shape","(","batch_size",",","seq_len",",","feature_dim",")","mask","(","torch.Tensor",")",":","bool","tensor","with","shape","(","batch_size",",","seq_len",")",".","Sequence","elements","that","are","False","are","invalid",".","Returns",":","Tensor","with","shape","(","batch_size",",","feature_dim",")"]
code: def forward(
      self, data: torch.Tensor, mask: Optional[torch.Tensor] = None
  ) -> torch.Tensor:
      """
      Args:
          data (torch.Tensor): tensor with shape (batch_size, seq_len, feature_dim)
          mask (torch.Tensor): bool tensor with shape (batch_size, seq_len).
              Sequence elements that are False are invalid.
  
      Returns:
          Tensor with shape (batch_size, feature_dim)
      """
      if mask is not None:
          # At least the first element of each masked batch row must be valid for
          # key_padding_mask.
          mask[:, 0] = True
          mask = ~mask
  
      out = self.encoder(
          src=data.transpose(0, 1), src_key_padding_mask=mask
      ).transpose(0, 1)
  
      return out[:, 0, :]
  
imports: from typing import List, Optional, Tuple
  import torch
  from pytorchvideo.layers.utils import set_attributes
  from torch import nn
  from torch.nn.utils.rnn import pack_padded_sequence
label_desc: Use image node_id 2 for calling the TransposeTransformerEncoder obj's underlying member method code with example usage: obj.forward(data, mask) and returns: out