class_docstr: Enables different values in a categorical feature to share some embeddings across.
class_docstr_tok: ["Enables","different","values","in","a","categorical","feature","to","share","some","embeddings","across","."]
code: def __init__(
      self,
      num_embed: int,
      embed_dim: int,
      add_shared_embed: bool = False,
      frac_shared_embed: float = 0.25,
  ):
      super().__init__()
      assert (
          frac_shared_embed < 1
      ), "'frac_shared_embed' must be less than 1"
  
      self.add_shared_embed = add_shared_embed
      self.embed = nn.Embedding(num_embed, embed_dim, padding_idx=0)
      self.embed.weight.data.clamp_(-2, 2)
      if add_shared_embed:
          col_embed_dim = embed_dim
      else:
          col_embed_dim = int(embed_dim * frac_shared_embed)
      self.shared_embed = nn.Parameter(
          torch.empty(1, col_embed_dim).uniform_(-1, 1)
      )
  
imports: import math
  from functools import partial
  from typing import Any, Dict, List, Optional, Tuple
  import torch
  from torch import nn
  from pytorch_tabular.models.common.layers.batch_norm import BatchNorm1d
  from pytorch_tabular.utils import _initialize_kaiming
label_desc: Use image node_id 1 to create a new SharedEmbeddings object from inherited base classes: nn with example: obj = SharedEmbeddings(num_embed, embed_dim, add_shared_embed, frac_shared_embed)