code: def ntwks_to_matrices(in_files, edge_key):
      first = _read_pickle(in_files[0])
      files = len(in_files)
      nodes = len(first.nodes())
      matrix = np.zeros((nodes, nodes, files))
      for idx, name in enumerate(in_files):
          graph = _read_pickle(name)
          for u, v, d in graph.edges(data=True):
              try:
                  graph[u][v]["weight"] = d[
                      edge_key
                  ]  # Setting the edge requested edge value as weight value
              except:
                  raise KeyError(
                      f"the graph edges do not have {edge_key} attribute"
                  )
          matrix[:, :, idx] = nx.to_numpy_array(
              graph
          )  # Retrieve the matrix
      return matrix
  
file_path: nipype/nipype/interfaces/cmtk/nbs.py
imports: import os.path
  import numpy
  import networkx
  import pickle
  from ...None import logging
  from ..base import LibraryBaseInterface, BaseInterfaceInputSpec, traits, File, TraitedSpec, InputMultiPath, OutputMultiPath, isdefined
  from .base import have_cv
label_desc: Use image node_id 2 for calling a global function with example usage: ntwks_to_matrices(in_files, edge_key) and returns: matrix