code: def tensorize(
      self, datapoint: GraphData[TNodeData, TEdgeData]
  ) -> Optional[
      TensorizedGraphData[TTensorizedNodeData, TTensorizedEdgeData]
  ]:
      if len(datapoint.node_information) > self.max_nodes_per_graph:
          self.LOGGER.warning(
              "Dropping graph with %s nodes."
              % len(datapoint.node_information)
          )
          return None
  
      if self.__edge_embedding_model is None:
          tensorized_edge_features = None
      else:
          tensorized_edge_features = []
          for edge_type in self.__edge_idx_to_type:
              edge_features_for_edge_type = datapoint.edge_features.get(
                  edge_type
              )
              if edge_features_for_edge_type is None:
                  # No edges of type `edge_type`
                  tensorized_edge_features.append([])
              else:
                  tensorized_edge_features.append(
                      [
                          self.__edge_embedding_model.tensorize(e)
                          for e in edge_features_for_edge_type
                      ]
                  )
  
      tensorized_data = TensorizedGraphData(
          adjacency_lists=list(self.__iterate_edge_types(datapoint)),
          node_tensorized_data=[
              enforce_not_None(
                  self.__node_embedding_model.tensorize(ni)
              )
              for ni in datapoint.node_information
          ],
          edge_features=tensorized_edge_features,
          reference_nodes={
              n: np.array(refs, dtype=np.int32)
              for n, refs in datapoint.reference_nodes.items()
          },
          num_nodes=len(datapoint.node_information),
      )
  
      num_edges = sum(
          len(adj) for adj in tensorized_data.adjacency_lists
      )
      if num_edges > self.max_graph_edges:
          self.LOGGER.warning(
              "Dropping graph with %s edges." % num_edges
          )
          return None
  
      return tensorized_data
  
imports: from typing_extensions import Final
  import logging
  import numpy
  import torch
  from collections import defaultdict
  from torch import nn
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Set, Tuple, TypeVar, Union
  from ptgnn.baseneuralmodel import AbstractNeuralModel, ModuleWithMetrics
  from ptgnn.baseneuralmodel.utils.data import enforce_not_None
  from ptgnn.neuralmodels.gnn.messagepassing.abstractmessagepassing import AbstractMessagePassingLayer
  from ptgnn.neuralmodels.gnn.structs import GnnOutput, GraphData, TensorizedGraphData
label_desc: Use image node_id 9 for calling the GraphNeuralNetworkModel obj's underlying member method code with example usage: obj.tensorize(datapoint) and returns: tensorized_data, None, None