class_docstr: Base class for nearest neighbors estimators.
code: def _init_params(
      self,
      n_neighbors=None,
      radius=None,
      algorithm="auto",
      leaf_size=30,
      metric="minkowski",
      p=2,
      metric_params=None,
      n_jobs=1,
  ):
      self.n_neighbors = n_neighbors
      self.radius = radius
      self.algorithm = algorithm
      self.leaf_size = leaf_size
      self.metric = metric
      self.metric_params = metric_params
      self.p = p
      self.n_jobs = n_jobs
  
      if algorithm not in ["auto", "brute", "kd_tree", "ball_tree"]:
          raise ValueError("unrecognized algorithm: '%s'" % algorithm)
  
      if algorithm == "auto":
          if metric == "precomputed":
              alg_check = "brute"
          else:
              alg_check = "ball_tree"
      else:
          alg_check = algorithm
  
      if callable(metric):
          if 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'"
                  % metric
              )
      elif metric not in VALID_METRICS[alg_check]:
          raise ValueError(
              "Metric '%s' not valid for algorithm '%s'"
              % (metric, algorithm)
          )
  
      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 = 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"
          )
  
      self._fit_X = None
      self._tree = None
      self._fit_method = None
  
imports: import warnings
  from abc import ABCMeta, abstractmethod
  import numpy
  from scipy.sparse import csr_matrix, issparse
  from .ball_tree import BallTree
  from .kd_tree import KDTree
  from ..base import BaseEstimator
  from ..metrics import pairwise_distances
  from ..metrics.pairwise import PAIRWISE_DISTANCE_FUNCTIONS
  from ..utils import check_X_y, check_array, _get_n_jobs, gen_even_slices
  from ..utils.fixes import argpartition
  from ..utils.multiclass import check_classification_targets
  from ..externals import six
  from ..externals.joblib import Parallel, delayed
  from ..exceptions import NotFittedError
  from ..exceptions import DataConversionWarning
label_desc: Use image node_id 2 for calling the NeighborsBase obj's underlying member method code with example usage: obj._init_params(n_neighbors, radius, algorithm, leaf_size, metric, p, metric_params, n_jobs) without return types