def get_maximum_samples_to_search_among(maximum_samples_to_search_among, X_unlabelled_np, nr_of_samples):
    """
    get_maximum_samples_to_search_among internal function used by the module

    Returns the number of samples that should be searched among. 
    If maximum_samples_to_search_among.lower() == "all", it returns the number of unlabelled samples that are available.
    If maximum_samples_to_search_among is a number it returns the the mininum of this number and the the number of unlabelled samples that are available.
    """
    try:
        nr_of_samples_int = int(nr_of_samples)

        if isinstance(maximum_samples_to_search_among, str) and maximum_samples_to_search_among.lower() == "all":
            print("Will search for samples to select among all " + str(len(X_unlabelled_np)) + " unlabelled samples.") 
            return len(X_unlabelled_np)    
        try:
            maximum_samples_to_search_among_int = int(maximum_samples_to_search_among)


            if maximum_samples_to_search_among_int > len(X_unlabelled_np):
                print("There are " + str(len(X_unlabelled_np)) + " unlabelled samples left. Will search for samples to select among those.") 
                return len(X_unlabelled_np)
            else:
                print("Will search for samples to select among " + str(maximum_samples_to_search_among_int) + " randomly selected unlabelled samples.")
                return maximum_samples_to_search_among_int
        except ValueError:
            print("The property maximum_samples_to_search_among can only take a numerical value or the string 'all', " + \
                      maximum_samples_to_search_among + " is not valid.")
            exit(1)
    except ValueError:
        print("The property nr_of_samples can only take a numerical value, " + str(nr_of_samples) + " is not valid.")
        exit(1)