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","."]
code: def __init__(
      self,
      vocab: List[str],
      embedding_size: int,
      representation: str = "dense",
      embeddings_trainable: bool = True,
      pretrained_embeddings: Optional[str] = None,
      force_embedding_size: bool = False,
      embeddings_on_cpu: bool = False,
      dropout: float = 0.0,
      embedding_initializer: Optional[str] = None,
  ):
      super().__init__()
  
      self.embeddings, self.embedding_size = embedding_matrix_on_device(
          vocab,
          embedding_size,
          representation=representation,
          embeddings_trainable=embeddings_trainable,
          pretrained_embeddings=pretrained_embeddings,
          force_embedding_size=force_embedding_size,
          embeddings_on_cpu=embeddings_on_cpu,
          embedding_initializer=embedding_initializer,
      )
      self.vocab_size = len(vocab)
  
      if dropout > 0:
          self.dropout = nn.Dropout(dropout)
      else:
          self.dropout = None
  
      self.register_buffer(
          "vocab_indices",
          torch.arange(self.vocab_size, dtype=torch.int32),
      )
  
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 1 to create a new EmbedWeighted object from inherited base classes: LudwigModule with example: obj = EmbedWeighted(vocab, embedding_size, representation, embeddings_trainable, pretrained_embeddings, force_embedding_size, embeddings_on_cpu, dropout, embedding_initializer)