def get_next_batch(x, y, batch_idx, batch_size):
    """ Fetch next batch from data set for training.

    :param x: Feature matrix of size (num_samples, num_features).
    :param y: Label matrix of size (num_samples, 1)
    :param batch_idx: Index of the current batch.
    :param batch_size: Size of the batch
    :return: Tuple containing the current x and y batch.
    """
    start = batch_idx * batch_size
    end = (batch_idx + 1) * batch_size
    end = min(end, len(x) + 1)
    return x[start:end], y[start:end]
