code: def from_networkit(g: Any) -> Tuple[Tensor, Optional[Tensor]]:
      r"""Converts a :class:`networkit.Graph` to a
      :obj:`(edge_index, edge_weight)` tuple.
      If the :class:`networkit.Graph` is not weighted, the returned
      :obj:`edge_weight` will be :obj:`None`.
  
      Args:
          g (networkkit.graph.Graph): A :obj:`networkit` graph object.
      """
      is_directed = g.isDirected()
      is_weighted = g.isWeighted()
  
      edge_indices, edge_weights = [], []
      for u, v, w in g.iterEdgesWeights():
          edge_indices.append([u, v])
          edge_weights.append(w)
          if not is_directed:
              edge_indices.append([v, u])
              edge_weights.append(w)
  
      edge_index = torch.tensor(edge_indices).t().contiguous()
      edge_weight = torch.tensor(edge_weights) if is_weighted else None
  
      return edge_index, edge_weight
  
file_path: pytorch_geometric/torch_geometric/utils/convert.py
imports: from collections import defaultdict
  from typing import Any, Dict, Iterable, List, Literal, Optional, Tuple, Union
  import scipy.sparse
  import torch
  from torch import Tensor
  from torch.utils.dlpack import from_dlpack, to_dlpack
  import torch_geometric
  from torch_geometric.utils.num_nodes import maybe_num_nodes
label_desc: Use image node_id 6 for calling a global function with example usage: from_networkit(g) and returns: edge_index,  edge_weight