code: def tensorize(
      self, datapoint: TypilusGraph
  ) -> Optional[TensorizedGraph2ClassSample]:
      graph_data, target_classes = self.__convert(datapoint)
      if len(target_classes) == 0:
          return None  # Sample contains no ground-truth annotations.
  
      graph_tensorized_data = self.__gnn_model.tensorize(graph_data)
  
      if graph_tensorized_data is None:
          return None  # Sample rejected by the GNN
  
      target_class_ids = []
      for target_cls in target_classes:
          if self.__try_simplify_unks and self.__target_vocab.is_unk(
              target_cls
          ):
              # TODO: Backoff on the type lattice. For now, just erase generics
              generic_start = target_cls.find("[")
              if generic_start != -1:
                  target_cls = target_cls[:generic_start]
          target_class_ids.append(
              self.__target_vocab.get_id_or_unk(target_cls)
          )
  
      return TensorizedGraph2ClassSample(
          graph=graph_tensorized_data,
          supernode_target_classes=target_class_ids,
      )
  
imports: from typing_extensions import TypedDict
  import numpy
  import torch
  from dpu_utils.mlutils import Vocabulary
  from torch import nn
  from typing import Any, Counter, Dict, Iterator, List, NamedTuple, Optional, Tuple, Union
  from ptgnn.baseneuralmodel import AbstractNeuralModel, ModuleWithMetrics
  from ptgnn.baseneuralmodel.utils.data import enforce_not_None
  from ptgnn.neuralmodels.gnn import GnnOutput, GraphData, TensorizedGraphData
  from ptgnn.neuralmodels.gnn.graphneuralnetwork import GraphNeuralNetwork, GraphNeuralNetworkModel
label_desc: Use image node_id 7 for calling the Graph2Class obj's underlying member method code with example usage: obj.tensorize(datapoint) and returns: TensorizedGraph2ClassSample, None, None