code: def dict_to_ndarray(d):
      """Convert a dictionary representation of an array (keys as indices) into a ndarray.
  
      Args:
        d: dict to be converted.
  
      Converts a dictionary representation of a sparse array into a ndarray. Array
      shape infered from maximum indices. Entries default to zero if unfilled.
  
      Example:
        >>> dict_to_ndarray({(0,0) : 3, (1,1) : 7})
        [[3, 0],
         [0, 7]]
  
      """
      assert len(
          d
      ), "Dictionary passed to dict_to_ndarray() must not be empty."
      inds = list(d.keys())
      ind_dims = len(inds[0])
      assert all(len(ind) == ind_dims for ind in inds)
      ind_shape = [
          max(ind[i] + 1 for ind in inds) for i in range(ind_dims)
      ]
  
      val0 = d[inds[0]]
      if isinstance(val0, np.ndarray):
          arr = np.zeros(ind_shape + list(val0.shape), dtype=val0.dtype)
      else:
          arr = np.zeros(ind_shape, dtype="float32")
  
      for ind, val in d.items():
          arr[ind] = val
      return arr
  
imports: import itertools
  import types
  from collections.abc import Iterable
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: dict_to_ndarray(d) and returns: arr