code: def _validate_data(
      self,
      X,
      y=None,
      reset=True,
      validate_separately=False,
      **check_params,
  ):
      if y is None:
          if self.requires_y:
              raise ValueError(
                  f"This {self.__class__.__name__} estimator "
                  f"requires y to be passed, but the target y is None."
              )
          X = _check_array(X, **check_params)
          out = X, y
      else:
          if validate_separately:
              # We need this because some estimators validate X and y
              # separately, and in general, separately calling _check_array()
              # on X and y isn't equivalent to just calling _check_X_y()
              # :(
              check_X_params, check_y_params = validate_separately
              X = _check_array(X, **check_X_params)
              y = _check_array(y, **check_y_params)
          else:
              X, y = _check_X_y(X, y, **check_params)
          out = X, y
  
      if check_params.get("ensure_2d", True):
          _check_n_features(self, X, reset=reset)
  
      return out
  
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 3 for calling the NeighborsCommonBase obj's underlying member method code with example usage: obj._validate_data(X, y, reset, validate_separately) and returns: out