code: def expand_relations(relation_dicts, window_size=3):
      max_n_samples = (
          max(
              [max(d.keys()) for d in relation_dicts]
              + [max(d.values()) for d in relation_dicts]
          )
          + 1
      )
      result = np.full(
          (len(relation_dicts) + 1, 2 * window_size + 1, max_n_samples),
          -1,
          dtype=np.int32,
      )
      reverse_relation_dicts = [invert_dict(d) for d in relation_dicts]
      for i in range(result.shape[0]):
          for j in range(window_size):
              result_index = (window_size) + (j + 1)
              if i + j + 1 >= len(relation_dicts):
                  result[i, result_index] = np.full(
                      max_n_samples, -1, dtype=np.int32
                  )
              else:
                  mapping = np.arange(max_n_samples)
                  for k in range(j + 1):
                      mapping = np.array(
                          [
                              relation_dicts[i + k].get(n, -1)
                              for n in mapping
                          ]
                      )
                  result[i, result_index] = mapping
  
          for j in range(0, -window_size, -1):
              result_index = (window_size) + (j - 1)
              if i + j - 1 < 0:
                  result[i, result_index] = np.full(
                      max_n_samples, -1, dtype=np.int32
                  )
              else:
                  mapping = np.arange(max_n_samples)
                  for k in range(0, j - 1, -1):
                      mapping = np.array(
                          [
                              reverse_relation_dicts[i + k - 1].get(
                                  n, -1
                              )
                              for n in mapping
                          ]
                      )
                  result[i, result_index] = mapping
  
      return result
  
imports: import numpy
  import numba
  from sklearn.base import BaseEstimator
  from sklearn.utils import check_array
  from umap.sparse import arr_intersect
  from umap.sparse import arr_union
  from umap.umap_ import UMAP, make_epochs_per_sample
  from umap.spectral import spectral_layout
  from umap.layouts import optimize_layout_aligned_euclidean
label_desc: Use image node_id 4 for calling a global function with example usage: expand_relations(relation_dicts, window_size) and returns: result