def compute_feedback_by_span_group(
    events: pd.DataFrame,
    feedback_name: str,
    feedback_function: Callable[
        [Any], Union[float, Tuple[float, Dict[str, Any]]]
    ],
    higher_is_better: bool,
    kwarg_to_selector: Dict[str, Selector],
    feedback_aggregator: Optional[Callable[[List[float]], float]] = None,
    raise_error_on_no_feedbacks_computed: bool = True,
) -> None:
    """
    Compute feedback based on span groups in events.

    Args:
        events: DataFrame containing trace events.
        feedback_name: Name of the feedback function.
        feedback_function: Function to compute feedback.
        higher_is_better: Whether higher values are better.
        kwarg_to_selector: Mapping from function kwargs to span selectors
        feedback_aggregator: Aggregator function to combine feedback scores.
        raise_error_on_no_feedbacks_computed:
            Raise an error if no feedbacks were computed. Default is True.
    """
    kwarg_groups = _group_kwargs_by_selectors(kwarg_to_selector)
    unflattened_inputs = _collect_inputs_from_events(
        events, kwarg_groups, kwarg_to_selector
    )
    record_id_to_record_root = _map_record_id_to_record_roots(events)
    unflattened_inputs = _validate_unflattened_inputs(
        unflattened_inputs,
        kwarg_groups,
        list(record_id_to_record_root.keys()),
        feedback_name,
    )
    flattened_inputs = _flatten_inputs(unflattened_inputs)
    flattened_inputs = _remove_already_computed_feedbacks(
        events, feedback_name, flattened_inputs
    )
    num_feedbacks_computed = _run_feedback_on_inputs(
        flattened_inputs,
        feedback_name,
        feedback_function,
        higher_is_better,
        feedback_aggregator,
        record_id_to_record_root,
    )
    if raise_error_on_no_feedbacks_computed and num_feedbacks_computed == 0:
        raise ValueError("No feedbacks were computed!")

    Compute feedback based on span groups in events.

    Args:
        events: DataFrame containing trace events.
        feedback_name: Name of the feedback function.
        feedback_function: Function to compute feedback.
        higher_is_better: Whether higher values are better.
        kwarg_to_selector: Mapping from function kwargs to span selectors
        feedback_aggregator: Aggregator function to combine feedback scores.
        raise_error_on_no_feedbacks_computed:
            Raise an error if no feedbacks were computed. Default is True.
    
src/feedback/trulens/feedback/computer.py