code: def _get_weights(dist, weights):
      """Get the weights from an array of distances and a parameter weights"""
      if weights in (None, "uniform"):
          return None
      elif 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
          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: import logging
  import numpy
  from pandas import DataFrame
  from scipy.stats import mode
  from sklearn.utils.extmath import weighted_mode
  from autogluon.common.utils.try_import import try_import_faiss
label_desc: Use image node_id 2 for calling a global function with example usage: _get_weights(dist, weights) and returns: None, dist, weights