class_docstr: Module to embed Set data types, works on multi-hot encoded input.
class_docstr_tok: ["Module","to","embed","Set","data","types",",","works","on","multi-hot","encoded","input","."]
docstr: Params:
      inputs: Boolean multi-hot tensor of size [batch x vocab_size], where
              inputs[b, i] indicates that token i is present in sample b.
docstr_tok: ["Params",":","inputs",":","Boolean","multi-hot","tensor","of","size","[","batch","x","vocab_size","]",",","where","inputs","[","b",",","i","]","indicates","that","token","i","is","present","in","sample","b","."]
code: def forward(
      self, inputs: torch.Tensor, mask: Optional[torch.Tensor] = None
  ) -> torch.Tensor:
      """
      Params:
          inputs: Boolean multi-hot tensor of size [batch x vocab_size], where
                  inputs[b, i] indicates that token i is present in sample b.
      """
      # Convert multi-hot input to input of indices
      inputs = inputs.int() * self.vocab_indices
      embedded = self.embeddings(inputs.long())
      # Mask out the 0th embedding
      mask = torch.unsqueeze(inputs, -1)
      embedded = embedded * mask
      # Sum over all positive tokens
      embedded = self.aggregation_function(embedded, dim=1)
      if self.dropout:
          embedded = self.dropout(embedded)
      return embedded
  
imports: import logging
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from ludwig.constants import TYPE
  from ludwig.modules.initializer_modules import get_initializer
  from ludwig.utils.data_utils import load_pretrained_embeddings
  from ludwig.utils.torch_utils import get_torch_device, LudwigModule
label_desc: Use image node_id 2 for calling the EmbedSet obj's underlying member method code with example usage: obj.forward(inputs, mask) and returns: embedded