code: def check_neighbors_object(nn_name, nn_object, additional_neighbor=0):
      """Check the objects is consistent to be a k nearest neighbors.
  
      Several methods in `imblearn` relies on k nearest neighbors. These objects
      can be passed at initialisation as an integer or as an object that has
      KNeighborsMixin-like attributes. This utility will create or clone said
      object, ensuring it is KNeighbors-like.
  
      Parameters
      ----------
      nn_name : str
          The name associated to the object to raise an error if needed.
  
      nn_object : int or KNeighborsMixin
          The object to be checked.
  
      additional_neighbor : int, default=0
          Sometimes, some algorithm need an additional neighbors.
  
      Returns
      -------
      nn_object : KNeighborsMixin
          The k-NN object.
      """
      if isinstance(nn_object, Integral):
          return NearestNeighbors(
              n_neighbors=nn_object + additional_neighbor
          )
      # _is_neighbors_object(nn_object)
      return clone(nn_object)
  
imports: import warnings
  from collections import OrderedDict
  from functools import wraps
  from inspect import Parameter, signature
  from numbers import Integral, Real
  import numpy
  from sklearn.base import clone
  from sklearn.neighbors import NearestNeighbors
  from sklearn.utils import check_array, column_or_1d
  from sklearn.utils.multiclass import type_of_target
  from sklearn.utils.validation import _num_samples
  from .fixes import _is_pandas_df
label_desc: Use image node_id 2 for calling a global function with example usage: check_neighbors_object(nn_name, nn_object, additional_neighbor) and returns: clone, NearestNeighbors