docstr: :param token_idxs: The subtoken ids in a [B, max_num_subtokens] matrix.
  :param lengths: A [B]-sized vector containing the lengths
  :return: a [B, D] matrix of D-sized representations, one per input example.
docstr_tok: [":","param","token_idxs",":","The","subtoken","ids","in","a","[","B",",","max_num_subtokens","]","matrix",".",":","param","lengths",":","A","[","B","]","-sized","vector","containing","the","lengths",":","return",":","a","[","B",",","D","]","matrix","of","D-sized","representations",",","one","per","input","example","."]
code: def forward(
      self, token_idxs: torch.Tensor, lengths: torch.Tensor
  ) -> torch.Tensor:
      """
      :param token_idxs: The subtoken ids in a [B, max_num_subtokens] matrix.
      :param lengths: A [B]-sized vector containing the lengths
      :return: a [B, D] matrix of D-sized representations, one per input example.
      """
      embedded = self.__embeddings(
          token_idxs
      )  # [B, max_num_subtokens, D]
      mask = torch.arange(
          embedded.shape[1], device=lengths.device
      ).unsqueeze(0) < lengths.unsqueeze(
          -1
      )  # [B, max_num_subtokens]
  
      if self.__subtoken_combination_kind == "mean":
          embedded = embedded * mask.unsqueeze(-1).float()
          embedded = embedded.sum(dim=-2) / (
              lengths.unsqueeze(-1).float() + 1e-10
          )  # [B, D]
      elif self.__subtoken_combination_kind == "sum":
          embedded = embedded * mask.unsqueeze(-1).float()
          embedded = embedded.sum(dim=-2)  # [B, D]
      elif self.__subtoken_combination_kind == "max":
          embedded.masked_fill_(
              mask=~mask.unsqueeze(-1), value=-math.inf
          )
          embedded, _ = embedded.max(dim=-2)  # [B, D]
      else:
          raise ValueError(
              f'Unrecognized subtoken combination "{self.__subtoken_combination_kind}".'
          )
      if self.__out_layer is not None:
          embedded = self.__out_layer(embedded)
      return self.__dropout_layer(embedded)
  
imports: from typing_extensions import Final, Literal
  import logging
  import math
  import numpy
  import torch
  import torch.nn
  from dpu_utils.codeutils import split_identifier_into_parts
  from dpu_utils.mlutils import BpeVocabulary, CharTensorizer, Vocabulary
  from typing import Any, Counter, Dict, List, NamedTuple, Optional, Union
  from ptgnn.baseneuralmodel import AbstractNeuralModel
  from ptgnn.neuralmodels.gnn.structs import AbstractNodeEmbedder
label_desc: Use image node_id 3 for calling the SubtokenUnitEmbedder obj's underlying member method code with example usage: obj.forward(token_idxs, lengths) and returns: self