'Returns n_neighbors of approximate nearest neighbors.
Parameters
X : array_like or sparse (CSR) matrix, shape (n_samples, n_features)
List of n_features-dimensional data points.  Each row
corresponds to a single query.
n_neighbors : int, optional (default = None)
Number of neighbors required. If not provided, this will
return the number specified at the initialization.
return_distance : boolean, optional (default = True)
Returns the distances of neighbors if set to True.
Returns
dist : array, shape (n_samples, n_neighbors)
Array representing the cosine distances to each point,
only present if return_distance=True.
ind : array, shape (n_samples, n_neighbors)
Indices of the approximate nearest points in the population
matrix.'

def kneighbors(self, X, n_neighbors=None, return_distance=True):

    if (not hasattr(self, 'hash_functions_')):
        raise ValueError('estimator    should    be    fitted.')
    if (n_neighbors is None):
        n_neighbors = self.n_neighbors
    X = check_array(X, accept_sparse='csr')
    (neighbors, distances) = ([], [])
    (bin_queries, max_depth) = self._query(X)
    for i in range(X.shape[0]):
        (neighs, dists) = self._get_candidates(X[[i]], max_depth[i], bin_queries[i], n_neighbors)
        neighbors.append(neighs)
        distances.append(dists)
    if return_distance:
        return (np.array(distances), np.array(neighbors))
    else:
        return np.array(neighbors)
