code: def __convert(
      self, typilus_graph: TypilusGraph
  ) -> Tuple[GraphData[str, None], List[str]]:
      def get_adj_list(adjacency_dict):
          for from_node_idx, to_node_idxs in adjacency_dict.items():
              from_node_idx = int(from_node_idx)
              for to_idx in to_node_idxs:
                  yield (from_node_idx, to_idx)
  
      edges = {}
      for edge_type, adj_dict in typilus_graph["edges"].items():
          adj_list: List[Tuple[int, int]] = list(get_adj_list(adj_dict))
          if len(adj_list) > 0:
              edges[edge_type] = np.array(adj_list, dtype=np.int32)
          else:
              edges[edge_type] = np.zeros((0, 2), dtype=np.int32)
  
      supernode_idxs_with_ground_truth: List[int] = []
      supernode_annotations: List[str] = []
      for supernode_idx, supernode_data in typilus_graph[
          "supernodes"
      ].items():
          if supernode_data["annotation"] in IGNORED_TYPES:
              continue
          if (
              not self.__tensorize_samples_with_no_annotation
              and supernode_data["annotation"] is None
          ):
              continue
          elif supernode_data["annotation"] is None:
              supernode_data["annotation"] = "??"
          supernode_idxs_with_ground_truth.append(int(supernode_idx))
          supernode_annotations.append(
              enforce_not_None(supernode_data["annotation"])
          )
  
      return (
          GraphData[str, None](
              node_information=typilus_graph["nodes"],
              edges=edges,
              reference_nodes={
                  "token-sequence": typilus_graph["token-sequence"],
                  "supernodes": supernode_idxs_with_ground_truth,
              },
          ),
          supernode_annotations,
      )
  
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 2 for calling the Graph2Class obj's underlying member method code with example usage: obj.__convert(typilus_graph) and returns: GraphData,  supernode_annotations