code: def from_numpy(x, undirected=True):
      G = Graph()
  
      if issparse(x):
          cx = x.tocoo()
          for i, j, v in zip(cx.row, cx.col, cx.data):
              G[i].append(j)
      else:
          raise Exception("Dense matrices not yet supported.")
  
      if undirected:
          G.make_undirected()
  
      G.make_consistent()
      return G
  
imports: import logging
  import sys
  from io import open
  from os import path
  from time import time
  from glob import glob
  from six.moves import range, zip, zip_longest
  from six import iterkeys
  from collections import defaultdict, Iterable
  import random
  from random import shuffle
  from itertools import product, permutations
  from scipy.io import loadmat
  from scipy.sparse import issparse
label_desc: Use image node_id 11 for calling a global function with example usage: from_numpy(x, undirected) and returns: G