(event_fn, t0, y0)
return combined_event_fn
We ensure all event functions are initially positive,
    so then we can combine them by taking a min.
We ensure all event functions are initially positive,
    so then we can combine them by taking a min.
We ensure all event functions are initially positive so then we can combine them by taking a min .
def combine_event_functions(event_fn, t0, y0):
    """
    We ensure all event functions are initially positive,
    so then we can combine them by taking a min.
    """
    with torch.no_grad():
        initial_signs = torch.sign(event_fn(t0, y0))

    def combined_event_fn(t, y):
        c = event_fn(t, y)
        return torch.min(c * initial_signs)

    return combined_event_fn
def combine_event_functions ( event_fn , t0 , y0 ) : with torch . no_grad ( ) : initial_signs = torch . sign ( event_fn ( t0 , y0 ) ) def combined_event_fn ( t , y ) : c = event_fn ( t , y ) return torch . min ( c * initial_signs ) return combined_event_fn