<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _borderlineSMOTE(X, y, minority_target, N, k):
 """ Returns synthetic minority samples. Parameters X : array-like, shape = [n__samples, n_features] Holds the minority and majority samples y : array-like, shape = [n__samples] Holds the class targets for samples minority_target : value for minority class N : percetange of new synthetic samples: n_synthetic_samples = N/100 * n_minority_samples. Can be < 100. k : int. Number of nearest neighbours. h : high in random.uniform to scale dif of snythetic sample Returns ------- safe : Safe minorities synthetic : Synthetic sample of minorities in danger zone danger : Minorities of danger zone """


    n_samples, _ = X.shape

    #Learn nearest neighbours on complete training set
    neigh = NearestNeighbors(n_neighbors = k)
    neigh.fit(X)

    safe_minority_indices = list()
    danger_minority_indices = list()

    for i in range(n_samples):
        if y[i] != minority_target: continue

        nn = neigh.kneighbors(X[i], return_distance=False)

        majority_neighbours = 0
        for n in nn[0]:
            if y[n] != minority_target:
                majority_neighbours += 1

        if majority_neighbours == len(nn):
            continue
        elif majority_neighbours < (len(nn)/2):
            logger.debug("Add sample to safe minorities.")
            safe_minority_indices.append(i)
        else:
            #DANGER zone
            danger_minority_indices.append(i)

    #SMOTE danger minority samples
    synthetic_samples = _SMOTE(X[danger_minority_indices], N, k, h = 0.5)

    return (X[safe_minority_indices],
            synthetic_samples,
            X[danger_minority_indices])