code: def forward(self, inputs: torch.Tensor) -> torch.Tensor:
      if isinstance(inputs, PackedSequence):
          inputs, lengths = pad_packed_sequence(
              inputs, batch_first=self.batch_first
          )
      # inputs -> bsz * num_words * dim
      size = inputs.size()
  
      # Tiling the full input on top of itself size[1] times
      exp_inputs_2 = inputs.unsqueeze(1).expand(
          size[0], size[1], size[1], size[2]
      )
      if self.attention_type == SlotAttentionType.CONCAT:
          # Tiling each row on top of itself size[1] times
          exp_inputs_1 = inputs.unsqueeze(2).expand(
              size[0], size[1], size[1], size[2]
          )
          catted = torch.cat((exp_inputs_1, exp_inputs_2), 3)
          attn_weights_add = F.softmax(
              self.attention_add(catted).squeeze(3), dim=2
          ).unsqueeze(2)
          context_add = torch.matmul(
              attn_weights_add, exp_inputs_2
          ).squeeze(2)
          output = torch.cat((inputs, context_add), 2)
      elif (
          self.attention_type == SlotAttentionType.MULTIPLY
          or self.attention_type == SlotAttentionType.DOT
      ):
          attended = (
              inputs
              if self.attention_type == SlotAttentionType.DOT
              else self.attention_mult(inputs)
          )
          attn_weights_mult = F.softmax(
              torch.matmul(inputs, torch.transpose(attended, 1, 2)),
              dim=2,
          ).unsqueeze(2)
          context_mult = torch.matmul(
              attn_weights_mult, exp_inputs_2
          ).squeeze(2)
          output = torch.cat((inputs, context_mult), 2)
      else:
          output = inputs
  
      return output
  
file_path: pytext/pytext/models/representations/slot_attention.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from pytext.config import ConfigBase
  from pytext.config.module_config import SlotAttentionType
  from pytext.models.module import Module
  from pytext.utils.usage import log_class_usage
  from torch.nn.utils.rnn import PackedSequence, pad_packed_sequence
label_desc: Use image node_id 2 for calling the SlotAttention obj's underlying member method code with example usage: obj.forward(inputs) and returns: output