class_docstr: Manages issues related to near-duplicate examples.
class_docstr_tok: ["Manages","issues","related","to","near-duplicate","examples","."]
code: def _build_statistics_dictionary(
      self, knn_graph: csr_matrix
  ) -> Dict[str, Dict[str, Any]]:
      statistics_dict: Dict[str, Dict[str, Any]] = {"statistics": {}}
  
      # Add the knn graph as a statistic if necessary
      graph_key = "weighted_knn_graph"
      old_knn_graph = self.datalab.get_info("statistics").get(
          graph_key, None
      )
      old_graph_exists = old_knn_graph is not None
      prefer_new_graph = (
          not old_graph_exists
          or knn_graph.nnz > old_knn_graph.nnz
          or self.metric
          != self.datalab.get_info("statistics").get("knn_metric", None)
      )
      if prefer_new_graph:
          statistics_dict["statistics"][graph_key] = knn_graph
          if self.metric is not None:
              statistics_dict["statistics"]["knn_metric"] = self.metric
  
      return statistics_dict
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union
  import warnings
  import numpy
  import pandas
  from scipy.sparse import csr_matrix
  from sklearn.neighbors import NearestNeighbors
  from sklearn.exceptions import NotFittedError
  from sklearn.utils.validation import check_is_fitted
  from cleanlab.datalab.internal.issue_manager import IssueManager
label_desc: Use image node_id 6 for calling the NearDuplicateIssueManager obj's underlying member method code with example usage: obj._build_statistics_dictionary(knn_graph) and returns: statistics_dict