code: def _get_weights(self, dist, weights):
      if weights in (None, "uniform"):
          return None
      if weights == "distance":
          # if user attempts to classify a point that was zero distance from one
          # or more training points, those training points are weighted as 1.0
          # and the other points as 0.0
          if dist.dtype is np.dtype(object):
              for point_dist_i, point_dist in enumerate(dist):
                  # check if point_dist is iterable
                  # (ex: RadiusNeighborClassifier.predict may set an element of
                  # dist to 1e-6 to represent an 'outlier')
                  if (
                      hasattr(point_dist, "__contains__")
                      and 0.0 in point_dist
                  ):
                      dist[point_dist_i] = point_dist == 0.0
                  else:
                      dist[point_dist_i] = 1.0 / point_dist
          else:
              with np.errstate(divide="ignore"):
                  dist = 1.0 / dist
              inf_mask = np.isinf(dist)
              inf_row = np.any(inf_mask, axis=1)
              dist[inf_row] = inf_mask[inf_row]
          return dist
      elif callable(weights):
          return weights(dist)
      else:
          raise ValueError(
              "weights not recognized: should be 'uniform', "
              "'distance', or a callable function"
          )
  
imports: from abc import ABCMeta
  from numbers import Integral
  import numpy
  from daal4py import bf_knn_classification_prediction, bf_knn_classification_training, kdtree_knn_classification_prediction, kdtree_knn_classification_training
  from onedal import _backend
  from ..common._estimator_checks import _check_is_fitted, _is_classifier, _is_regressor
  from ..common._mixin import ClassifierMixin, RegressorMixin
  from ..common._policy import _get_policy
  from ..datatypes import _convert_to_supported, from_table, to_table
  from ..utils import _check_array, _check_classification_targets, _check_n_features, _check_X_y, _column_or_1d, _num_samples
label_desc: Use image node_id 4 for calling the NeighborsCommonBase obj's underlying member method code with example usage: obj._get_weights(dist, weights) and returns: None, dist, weights