class_docstr: Find closest anchors using :class:`scipy.sparse.csgraph`.
class_docstr_tok: ["Find","closest","anchors","using",":","class",":","`","scipy.sparse.csgraph","`","."]
code: def __call__(
      self,
      edge_index: numpy.ndarray,
      anchors: numpy.ndarray,
      k: int,
      num_entities: Optional[int] = None,
  ) -> numpy.ndarray:  # noqa: D102
      # convert to adjacency matrix
      adjacency = edge_index_to_sparse_matrix(
          edge_index=torch.as_tensor(edge_index, dtype=torch.long)
      ).coalesce()
      # convert to scipy sparse csr
      adjacency = scipy.sparse.coo_matrix(
          (adjacency.values(), adjacency.indices()),
          shape=adjacency.shape,
      ).tocsr()
      # compute distances between anchors and all nodes, shape: (num_anchors, num_entities)
      distances = scipy.sparse.csgraph.shortest_path(
          csgraph=adjacency,
          directed=False,
          return_predecessors=False,
          unweighted=True,
          indices=anchors,
      )
      # TODO: padding for unreachable?
      return self.topk_argpartition(array=distances, k=k).T
  
imports: import logging
  from abc import ABC, abstractmethod
  from typing import Iterable, Optional
  import numpy
  import scipy.sparse
  import torch
  from class_resolver import ClassResolver, OptionalKwargs
  from torch_ppr import page_rank
  from torch_ppr.utils import edge_index_to_sparse_matrix, prepare_page_rank_adjacency, prepare_x0
  from tqdm.auto import tqdm
  from .utils import ensure_num_entities
  from ...typing import DeviceHint
  from ...utils import ExtraReprMixin, format_relative_comparison, resolve_device
label_desc: Use image node_id 3 for calling the CSGraphAnchorSearcher obj's underlying member method code with example usage: obj.__call__(edge_index, anchors, k, num_entities) and returns: self