code: def k_hop_sparse_subgraph(a, node_idx, k, transformer=None):
      """
      Computes the subgraph containing all the neighbors of `node_idx` up to the k-th order.
      If `a` is not the binary adjacency matrix a  `transformer` should be passed.
      **Arguments**
      - `a`: sparse `(n_nodes, n_nodes)` graph tensor;
      - `node_idx`: center node;
      - `k`: order of neighbor;
      - `transformer`: one of the functions from the `spektral.transforms` module,
         needed to convert the binary adjacency matrix into the correct format for the model;
      """
      if a.dtype != tf.float32:
          a = tf.cast(a, tf.float32)
  
      if transformer:
          a = binary_adj_converter(a)
  
      power_a = tf.sparse.eye(a.shape[0])
      k_neighs = np.zeros(a.shape[0]).astype("float32").reshape(1, -1)
      k_neighs[0, node_idx] = 1
  
      for _ in range(k - 1):
          power_a = dot(power_a, a)
          temp = tf.sparse.slice(
              power_a, start=[node_idx, 0], size=[1, power_a.shape[0]]
          )
          k_neighs += tf.sparse.to_dense(temp)
  
      comp_graph = tf.sparse.add(
          a * tf.reshape(k_neighs, (-1, 1)), a * k_neighs
      )
      is_nonzero = tf.not_equal(comp_graph.values, 0)
      comp_graph = tf.sparse.retain(comp_graph, is_nonzero)
      comp_graph = tf.sign(comp_graph)
  
      if transformer:
          comp_graph = sp_tensor_to_sp_matrix(comp_graph)
          comp_graph = transformer(comp_graph)
          return sp_matrix_to_sp_tensor(comp_graph)
      else:
          return comp_graph
  
file_path: spektral/spektral/models/gnn_explainer.py
imports: import networkx
  import numpy
  import tensorflow
  from scipy.sparse import csr_matrix
  from spektral.layers import MessagePassing
  from spektral.layers.convolutional.conv import Conv
  from spektral.layers.ops import dot
  from spektral.utils.sparse import sp_matrix_to_sp_tensor
label_desc: Use image node_id 1 for calling a global function with example usage: k_hop_sparse_subgraph(a, node_idx, k, transformer) and returns: sp_matrix_to_sp_tensor, comp_graph