code: def _check_weights(weights):
      """Check to make sure weights are valid"""
      if weights in (None, "uniform", "distance"):
          return weights
      elif callable(weights):
          return weights
      else:
          raise ValueError(
              "weights not recognized: should be 'uniform', "
              "'distance', or a callable function"
          )
  
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 1 for calling a global function with example usage: _check_weights(weights) and returns: weights, weights