<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def solution(events, slots, objective_function=None, solver=None, **kwargs):
 """Compute a schedule in solution form Parameters events : list or tuple of :py:class:`resources.Event` instances slots : list or tuple of :py:class:`resources.Slot` instances solver : pulp.solver a pulp solver objective_function: callable from lp_problem.objective_functions kwargs : keyword arguments arguments for the objective function Returns ------- list A list of tuples giving the event and slot index (for the given events and slots lists) for all scheduled items. Example ------- For a solution where * event 0 is scheduled in slot 1 * event 1 is scheduled in slot 4 * event 2 is scheduled in slot 5 the resulting list would be:: [(0, 1), (1, 4), (2, 5)] """

    shape = Shape(len(events), len(slots))
    problem = pulp.LpProblem()
    X = lp.utils.variables(shape)
    beta = pulp.LpVariable("upper_bound")

    for constraint in lp.constraints.all_constraints(
        events, slots, X, beta, 'lpsum'
    ):
        problem += constraint.condition

    if objective_function is not None:
        problem += objective_function(events=events, slots=slots, X=X,
                                      beta=beta,
                                      **kwargs)

    status = problem.solve(solver=solver)
    if status == 1:
        return [item for item, variable in X.items() if variable.value() > 0]
    else:
        raise ValueError('No valid solution found')