class_docstr: A class for extending an embedding layer with additional tokens while also leaving the old
  and new embeddings as separate nn.Module instances. This allows only the new embeddings to be
  trained, for instance.
class_docstr_tok: ["A","class","for","extending","an","embedding","layer","with","additional","tokens","while","also","leaving","the","old","and","new","embeddings","as","separate","nn.Module","instances",".","This","allows","only","the","new","embeddings","to","be","trained",",","for","instance","."]
code: def __init__(
      self,
      original_embedding: nn.Module,
      new_embedding_weights: torch.Tensor,
  ) -> None:
      super().__init__()
      self.original_embedding = original_embedding
      (
          self.old_embedding_vocab_size,
          self.embedding_dim,
      ) = self.original_embedding.weight.shape
      assert (
          new_embedding_weights.shape[-1] == self.embedding_dim
      ), "new_embedding_weights must have the same embedding_dim as the original_embedding"
      self.new_embedding = nn.Embedding.from_pretrained(
          embeddings=new_embedding_weights, freeze=False
      )
  
imports: import torch
  import torch.nn
label_desc: Use image node_id 1 to create a new ExtendedEmbedding object from inherited base classes: nn with example: obj = ExtendedEmbedding(original_embedding, new_embedding_weights)