def execute_scripts()

in src/open_r1/utils/code_providers.py [0:0]


    def execute_scripts(self, scripts: List[str], languages: List[str]) -> List[float]:
        """Execute scripts using E2B sandboxes.

        If e2b_router_url is provided, uses the RoutedSandbox for batch processing.
        Otherwise, uses direct AsyncSandbox with parallelization.
        """
        if self.e2b_router_url is not None:
            routed_sandbox = RoutedSandbox(router_url=self.e2b_router_url)

            executions = routed_sandbox.run_code(
                scripts=scripts,
                languages=languages,
                timeout=30,
                request_timeout=28,
            )

            rewards = []
            for execution in executions:
                try:
                    reward = float(execution.text)
                    rewards.append(reward)
                except Exception:
                    rewards.append(None)
            return rewards

        try:
            rewards = self._run_async_from_sync(scripts, languages, self.num_parallel)
        except Exception as e:
            print(f"Error from E2B executor: {e}")
            rewards = [0.0] * len(scripts)

        return rewards