class_docstr: Select closest anchors as the nodes with the largest personalized page rank.
  
  .. seealso::
      http://web.stanford.edu/class/cs224w/slides/04-pagerank.pdf
class_docstr_tok: ["Select","closest","anchors","as","the","nodes","with","the","largest","personalized","page","rank",".","..","seealso",":",":","http",":","\/\/web.stanford.edu\/class\/cs224w\/slides\/04-pagerank.pdf"]
docstr: Yield batches of PPR values for each anchor from each entities' perspective.
  
  :param edge_index: shape: (2, m)
      the edge index.
  :param anchors: shape: `(num_anchors,)`
      the anchor IDs.
  :param num_entities:
      The number of entities. Will be calculated on-the-fly if not given
  
  :yields: shape: (batch_size, num_anchors)
      batches of anchor PPRs.
docstr_tok: ["Yield","batches","of","PPR","values","for","each","anchor","from","each","entities","'","perspective",".",":","param","edge_index",":","shape",":","(","2",",","m",")","the","edge","index",".",":","param","anchors",":","shape",":","`","(","num_anchors",",",")","`","the","anchor","IDs",".",":","param","num_entities",":","The","number","of","entities",".","Will","be","calculated","on-the-fly","if","not","given",":","yields",":","shape",":","(","batch_size",",","num_anchors",")","batches","of","anchor","PPRs","."]
code: def _iter_ppr(
      self,
      edge_index: numpy.ndarray,
      anchors: numpy.ndarray,
      num_entities: Optional[int] = None,
  ) -> Iterable[torch.Tensor]:
      """
      Yield batches of PPR values for each anchor from each entities' perspective.
  
      :param edge_index: shape: (2, m)
          the edge index.
      :param anchors: shape: `(num_anchors,)`
          the anchor IDs.
      :param num_entities:
          The number of entities. Will be calculated on-the-fly if not given
  
      :yields: shape: (batch_size, num_anchors)
          batches of anchor PPRs.
      """
      # prepare adjacency matrix only once
      adj = prepare_page_rank_adjacency(
          edge_index=torch.as_tensor(edge_index, dtype=torch.long),
          num_nodes=num_entities,
      )
      # prepare result
      n = adj.shape[0]
      # progress bar?
      progress = range(0, n, self.batch_size)
      if self.use_tqdm:
          progress = tqdm(progress, unit="batch", unit_scale=True)
      # batch-wise computation of PPR
      anchors = torch.as_tensor(anchors, dtype=torch.long)
      for start in progress:
          # run page-rank calculation, shape: (batch_size, n)
          ppr = page_rank(
              adj=adj,
              x0=prepare_x0(
                  indices=range(start, start + self.batch_size), n=n
              ),
              **self.page_rank_kwargs,
          )
          # select PPR values for the anchors, shape: (batch_size, num_anchors)
          yield ppr[:, anchors.to(ppr.device)]
  
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 5 for calling the PersonalizedPageRankAnchorSearcher obj's underlying member method code with example usage: obj._iter_ppr(edge_index, anchors, num_entities) without return types