class_docstr: Base class for nearest neighbors estimators.
class_docstr_tok: ["Base","class","for","nearest","neighbors","estimators","."]
code: def _check_algorithm_metric(self):
      if self.algorithm not in [
          "auto",
          "brute",
          "kd_tree",
          "ball_tree",
          "faiss",
          "proxima",
      ]:
          raise ValueError(
              f"unrecognized algorithm: '{self.algorithm}'"
          )
  
      if self.algorithm == "auto":
          if self.metric == "precomputed":
              alg_check = "brute"
          elif (
              callable(self.metric)
              or self.metric in VALID_METRICS["ball_tree"]
          ):
              alg_check = "ball_tree"
          else:
              alg_check = "brute"
      else:
          alg_check = self.algorithm
  
      if callable(self.metric):
          if self.algorithm == "kd_tree":
              # callable metric is only valid for brute force and ball_tree
              raise ValueError(
                  "kd_tree algorithm does not support callable metric '%s'"
                  % self.metric
              )
      elif self.metric not in VALID_METRICS[alg_check]:
          raise ValueError(
              "Metric '%s' not valid. Use "
              "sorted(sklearn.neighbors.VALID_METRICS['%s']) "
              "to get valid options. "
              "Metric can also be a callable function."
              % (self.metric, alg_check)
          )
  
      if self.metric_params is not None and "p" in self.metric_params:
          warnings.warn(
              "Parameter p is found in metric_params. "
              "The corresponding parameter from __init__ "
              "is ignored.",
              SyntaxWarning,
              stacklevel=3,
          )
          effective_p = self.metric_params["p"]
      else:
          effective_p = self.p
  
      if self.metric in ["wminkowski", "minkowski"] and effective_p < 1:
          raise ValueError(
              "p must be greater than one for minkowski metric"
          )
  
imports: import warnings
  from abc import ABCMeta, abstractmethod
  import numpy
  from sklearn.base import BaseEstimator, MultiOutputMixin
  from ...None import tensor
  from ...tensor.reshape.reshape import _reshape
  from ..metrics.pairwise import PAIRWISE_DISTANCE_FUNCTIONS
  from ..metrics import pairwise_distances_topk
  from ..utils import check_array
  from ..utils.validation import check_is_fitted
  from ._ball_tree import create_ball_tree, ball_tree_query, SklearnBallTree
  from ._kd_tree import create_kd_tree, kd_tree_query, SklearnKDTree
  from ._faiss import build_faiss_index, faiss_query, METRIC_TO_FAISS_METRIC_TYPE
  from ._proxima import build_proxima_index, proxima_query, METRIC_TO_PROXIMA_METRIC_TYPE
  from ._kneighbors_graph import KNeighborsGraph
label_desc: Use image node_id 2 for calling the NeighborsBase obj's underlying member method code with example usage: obj._check_algorithm_metric() without return types