class_docstr: Module to embed Bag data type, works on input of token frequencies.
class_docstr_tok: ["Module","to","embed","Bag","data","type",",","works","on","input","of","token","frequencies","."]
docstr: Params:
      inputs: Tensor of frequencies, where inputs[b, i] represents
              frequency of token i in sample b of batch.
docstr_tok: ["Params",":","inputs",":","Tensor","of","frequencies",",","where","inputs","[","b",",","i","]","represents","frequency","of","token","i","in","sample","b","of","batch","."]
code: def forward(
      self, inputs: torch.Tensor, mask: Optional[torch.Tensor] = None
  ) -> torch.Tensor:
      """
      Params:
          inputs: Tensor of frequencies, where inputs[b, i] represents
                  frequency of token i in sample b of batch.
      """
      # Convert to multi-hot input
      signed_input = (inputs != 0).type(torch.int32)
      multiple_hot_indexes = signed_input * self.vocab_indices
      embedded = self.embeddings(multiple_hot_indexes)
      # Mask out the 0th embedding
      mask = torch.unsqueeze(inputs, -1)
      weighted_embedded = embedded * mask
      # Sum over the all the positive indices
      embedded_reduced = torch.sum(weighted_embedded, dim=1)
      if self.dropout:
          embedded_reduced = self.dropout(embedded_reduced)
      return embedded_reduced
  
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 EmbedWeighted obj's underlying member method code with example usage: obj.forward(inputs, mask) and returns: embedded_reduced