def teacher(i, K, categories, output_activations):
    """
    Function that calculates the feedback in learning, which is supplied in the form of teacher values (equation 4b in
    [Krus92]_)

    Parameters
    ----------
    i : int
        Stimulus ID or stimulus number
    K : int
        Category number
    categories : list
        This is the list that indicates which stimulus belongs to which category. For example, out of 5 stimuli, if
        stimuli #0, #2, #4 belongs to category 0 and the rest belongs to category 1, then
        categories_Idx = [[0,2,4],[1,3]]
    output_activations : list
        This is the list containing the activations of each node in the output category layer

    Returns
    -------
    float
        Feedback of the model's performance to the current stimulus in the form of a value that is used in the learning
        phase.
    """
    num_categories = len(categories)
    correct_category = 0
    for k in range(num_categories):
        if i in categories[k]:
            correct_category = k

    if correct_category == K:
        return max(1, output_activations[K])
    else:
        return min(-1, output_activations[K])