def get_extra_results(self, trainer: "pl.Trainer") -> dict[str, Any]:
        """Gather extra state from the Trainer and return it as a dictionary for sending back to the main process. To
        avoid issues with memory sharing, we convert tensors to bytes.

        Args:
            trainer: reference to the Trainer.

        Returns:
            A dictionary with items to send back to the main process where :meth:`update_main_process_results` will
            process this output.

        """
        callback_metrics = apply_to_collection(trainer.callback_metrics, Tensor, lambda t: t.cpu())
        buffer = io.BytesIO()
        torch.save(callback_metrics, buffer)
        # send tensors as bytes to avoid issues with memory sharing
        return {"callback_metrics_bytes": buffer.getvalue()}
Gather extra state from the Trainer and return it as a dictionary for sending back to the main process. To
        avoid issues with memory sharing, we convert tensors to bytes.

        Args:
            trainer: reference to the Trainer.

        Returns:
            A dictionary with items to send back to the main process where :meth:`update_main_process_results` will
            process this output.

        
src/lightning/pytorch/strategies/launchers/multiprocessing.py