async def _prepare_instance(self, snapshot_id=None) -> Instance:
        """
        Prepare and start a MorphCloud instance.

        Args:
          snapshot_id: Optional snapshot ID to use. If None, will get or create base snapshot.

        Returns:
          Instance: The ready-to-use MorphCloud instance

        Raises:
          TimeoutError: If instance fails to start or become ready
        """

        if not snapshot_id:
            snapshot = await self._get_or_create_base_snapshot()
            snapshot_id = snapshot.id

        try:
            instance = await self.client.instances.astart(
                snapshot_id, ttl_seconds=600
            )  # Auto-terminate after 10 minutes
            await instance.await_until_ready(timeout=300)
            return instance
        except asyncio.TimeoutError as e:
            print(f"Timeout while preparing instance: {str(e)}")
            if instance:
                try:
                    await instance.astop()
                except Exception:
                    pass
            raise

        Prepare and start a MorphCloud instance.

        Args:
          snapshot_id: Optional snapshot ID to use. If None, will get or create base snapshot.

        Returns:
          Instance: The ready-to-use MorphCloud instance

        Raises:
          TimeoutError: If instance fails to start or become ready
        
src/open_r1/utils/competitive_programming/morph_client.py