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 forward(self, input_ids: torch.Tensor) -> torch.Tensor:
      output = torch.zeros(
          *input_ids.shape, self.embedding_dim, device=input_ids.device
      )
      idxs_for_old_embedding = input_ids < self.old_embedding_vocab_size
      idxs_for_new_embedding = torch.logical_not(idxs_for_old_embedding)
      inputs_ids_for_old_embedding = input_ids[idxs_for_old_embedding]
      inputs_ids_for_new_embedding = (
          input_ids[idxs_for_new_embedding]
          - self.old_embedding_vocab_size
      )
  
      output[idxs_for_old_embedding] = self.original_embedding(
          inputs_ids_for_old_embedding
      )
      output[idxs_for_new_embedding] = self.new_embedding(
          inputs_ids_for_new_embedding
      )
  
      return output
  
imports: import torch
  import torch.nn
label_desc: Use image node_id 2 for calling the ExtendedEmbedding obj's underlying member method code with example usage: obj.forward(input_ids) and returns: output