class_docstr: Item-item nearest-neighbor collaborative filtering with ratings. This item-item implementation
  is not terribly configurable; it hard-codes design decisions found to work well in the previous
  Java-based LensKit code :cite:p:`Ekstrand2011-bp`.  This implementation is based on the description
  of item-based CF by :cite:t:`Deshpande2004-ht`, and produces results equivalent to Java LensKit.
  
  The k-NN predictor supports several aggregate functions:
  
  ``weighted-average``
      The weighted average of the user's rating values, using item-item similarities as
      weights.
  
  ``sum``
      The sum of the similarities between the target item and the user's rated items,
      regardless of the rating the user gave the items.
  
  Args:
      nnbrs(int):
          the maximum number of neighbors for scoring each item (``None`` for unlimited)
      min_nbrs(int): the minimum number of neighbors for scoring each item
      min_sim(float): minimum similarity threshold for considering a neighbor
      save_nbrs(float):
          the number of neighbors to save per item in the trained model
          (``None`` for unlimited)
      feedback(str):
          Control how feedback should be interpreted.  Specifies defaults for the other
          settings, which can be overridden individually; can be one of the following values:
  
          ``explicit``
              Configure for explicit-feedback mode: use rating values, center ratings, and
              use the ``weighted-average`` aggregate method for prediction.  This is the
              default setting.
  
          ``implicit``
              Configure for implicit-feedback mode: ignore rating values, do not center ratings,
              and use the ``sum`` aggregate method for prediction.
      center(bool):
          whether to normalize (mean-center) rating vectors prior to computing similarities
          and aggregating user rating values.  Defaults to ``True``; turn this off when working
          with unary data and other data types that don't respond well to centering.
      aggregate(str):
          the type of aggregation to do. Can be ``weighted-average`` (the default) or ``sum``.
      use_ratings(bool):
          whether or not to use the rating values. If ``False``, it ignores rating values and
          considers an implicit feedback signal of 1 for every (user,item) pair present.
  
  Attributes:
      item_index_(pandas.Index): the index of item IDs.
      item_means_(numpy.ndarray): the mean rating for each known item.
      item_counts_(numpy.ndarray): the number of saved neighbors for each item.
      sim_matrix_(matrix.CSR): the similarity matrix.
      user_index_(pandas.Index): the index of known user IDs for the rating matrix.
      rating_matrix_(matrix.CSR): the user-item rating matrix for looking up users' ratings.
code: def _compute_similarities(self, rmat):
      trmat = rmat.transpose()
      nitems = trmat.nrows
      m_nbrs = self.save_nbrs
      if m_nbrs is None or m_nbrs < 0:
          m_nbrs = 0
  
      bounds = _make_blocks(nitems, 1000)
      _logger.info(
          "[%s] splitting %d items (%d ratings) into %d blocks",
          self._timer,
          nitems,
          trmat.nnz,
          len(bounds),
      )
      blocks = [trmat.subset_rows(sp, ep) for (sp, ep) in bounds]
  
      _logger.info("[%s] computing similarities", self._timer)
      ptrs = List(bounds)
      nbs = List(blocks)
      if not nbs:
          # oops, this is the bad place
          # in non-JIT node, List doesn't actually make the list
          nbs = blocks
          ptrs = bounds
      s_blocks = _sim_blocks(trmat, nbs, ptrs, self.min_sim, m_nbrs)
  
      nnz = sum(b.nnz for b in s_blocks)
      tot_rows = sum(b.nrows for b in s_blocks)
      _logger.info(
          "[%s] computed %d similarities for %d items in %d blocks",
          self._timer,
          nnz,
          tot_rows,
          len(s_blocks),
      )
      row_nnzs = np.concatenate([b.row_nnzs() for b in s_blocks])
      assert (
          len(row_nnzs) == nitems
      ), "only have {} rows for {} items".format(len(row_nnzs), nitems)
  
      smat = CSR.empty(nitems, nitems, row_nnzs)
      start = 0
      for bi, b in enumerate(s_blocks):
          bnr = b.nrows
          end = start + bnr
          v_sp = smat.rowptrs[start]
          v_ep = smat.rowptrs[end]
          _logger.debug(
              "block %d (%d:%d) has %d entries, storing in %d:%d",
              bi,
              start,
              end,
              b.nnz,
              v_sp,
              v_ep,
          )
          smat.colinds[v_sp:v_ep] = b.colinds
          smat.values[v_sp:v_ep] = b.values
          start = end
  
      _logger.info(
          "[%s] sorting similarity matrix with %d entries",
          self._timer,
          smat.nnz,
      )
      _sort_nbrs(smat)
  
      return smat
  
imports: from sys import intern
  import logging
  import warnings
  import pandas
  import numpy
  import scipy.sparse
  import scipy.sparse.linalg
  from csr import CSR, create_from_sizes, create_empty
  import csr.kernel
  from numba import njit, prange
  from numba.typed import List
  from lenskit import util, DataWarning, ConfigWarning
  from lenskit.data import sparse_ratings
  from lenskit.sharing import in_share_context
  from lenskit.util.parallel import is_mp_worker
  from lenskit.util.accum import kvp_minheap_insert, kvp_minheap_sort
  from .None import Predictor
label_desc: Use image node_id 6 for calling the ItemItem obj's underlying member method code with example usage: obj._compute_similarities(rmat) and returns: smat