def _reduce_gradients_mean(gradients: Set[Variable], backward_engine: EngineLM) -> Variable:
    """A function to reduce gradients by taking the "mean" of the gradients. 
    In this case, we use a summarization model to summarize the gradients.
    This can be helpful in batch training, where we want to average the gradients over a batch.

    :param gradients: Gradients to summarize together
    :type gradients: Set[Variable]
    :param backward_engine: The engine to summarize gradients. 
    :type backward_engine: EngineLM
    :return: The reduce(summarized) gradients
    :rtype: Variable
    """
    gradient_reduce_prompt = construct_reduce_prompt(gradients)
    reduced_gradients = backward_engine(gradient_reduce_prompt, system_prompt=REDUCE_MEAN_SYSTEM_PROMPT)
    gradient_descriptions = set([g.get_role_description() for g in gradients])
    gradient_descriptions = ", ".join(gradient_descriptions)
    reduced_gradients_variable = Variable(reduced_gradients, role_description=gradient_descriptions)
    logger.info(f"Reduced gradients", extra={"reduced_gradients": reduced_gradients_variable.value})
    # TODO: We need to add context for these gradients
    # Otherwise, .get_gradient_and_context_text() will return an empty string
    logger.info(f"Reduced gradients", extra={"reduced_gradients": reduced_gradients_variable.value})
    return reduced_gradients_variable
A function to reduce gradients by taking the "mean" of the gradients. 
    In this case, we use a summarization model to summarize the gradients.
    This can be helpful in batch training, where we want to average the gradients over a batch.

    :param gradients: Gradients to summarize together
    :type gradients: Set[Variable]
    :param backward_engine: The engine to summarize gradients. 
    :type backward_engine: EngineLM
    :return: The reduce(summarized) gradients
    :rtype: Variable
    
textgrad/autograd/algebra.py