code: def _dict_to_numpy_array2(d, mapping=None):
      """Convert a dictionary of dictionaries to a 2d numpy array
      with optional mapping.
  
      """
      import numpy as np
  
      if mapping is None:
          s = set(d.keys())
          for k, v in d.items():
              s.update(v.keys())
          mapping = dict(zip(s, range(len(s))))
      n = len(mapping)
      a = np.zeros((n, n))
      for k1, i in mapping.items():
          for k2, j in mapping.items():
              try:
                  a[i, j] = d[k1][k2]
              except KeyError:
                  pass
      return a
  
imports: import sys
  import uuid
  import warnings
  from collections import defaultdict, deque
  from collections.abc import Iterable, Iterator, Sized
  from itertools import chain, tee
  import networkx
label_desc: Use image node_id 4 for calling a global function with example usage: _dict_to_numpy_array2(d, mapping) and returns: a