class_docstr: Learns default values to fill invalid entries within input tensors. The
  invalid entries are represented by a mask which is passed into forward alongside
  the input tensor. Note the default value is only used if all entries in the batch row are
  invalid rather than just a portion of invalid entries within each batch row.
class_docstr_tok: ["Learns","default","values","to","fill","invalid","entries","within","input","tensors",".","The","invalid","entries","are","represented","by","a","mask","which","is","passed","into","forward","alongside","the","input","tensor",".","Note","the","default","value","is","only","used","if","all","entries","in","the","batch","row","are","invalid","rather","than","just","a","portion","of","invalid","entries","within","each","batch","row","."]
docstr: Args:
      x (torch.Tensor): tensor of shape (batch_size, feature_dim).
      mask (torch.Tensor): bool tensor of shape (batch_size, seq_len) If all elements
          in the batch dimension are False the learned default parameter is used for
          that batch element.
  
  Returns:
      Tensor with shape (batch_size, feature_dim)
docstr_tok: ["Args",":","x","(","torch.Tensor",")",":","tensor","of","shape","(","batch_size",",","feature_dim",")",".","mask","(","torch.Tensor",")",":","bool","tensor","of","shape","(","batch_size",",","seq_len",")","If","all","elements","in","the","batch","dimension","are","False","the","learned","default","parameter","is","used","for","that","batch","element",".","Returns",":","Tensor","with","shape","(","batch_size",",","feature_dim",")"]
code: def forward(
      self, x: torch.Tensor, mask: torch.Tensor
  ) -> torch.Tensor:
      """
      Args:
          x (torch.Tensor): tensor of shape (batch_size, feature_dim).
          mask (torch.Tensor): bool tensor of shape (batch_size, seq_len) If all elements
              in the batch dimension are False the learned default parameter is used for
              that batch element.
  
      Returns:
          Tensor with shape (batch_size, feature_dim)
      """
      # Determine which rows have no valid entries and use these for the default value mask.
      mask = mask.view(mask.shape[0], -1).any(dim=-1)
      for i in range(1, x.dim()):
          mask = mask.unsqueeze(i)
      x = x * mask.float() + self._learned_defaults * (1 - mask.float())
      return x
  
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 LearnMaskedDefault obj's underlying member method code with example usage: obj.forward(x, mask) and returns: x