def detect() -> bool:
        """Returns ``True`` if the `mpi4py` package is installed and MPI returns a world size greater than 1."""
        if not _MPI4PY_AVAILABLE:
            return False

        from mpi4py import MPI

        return MPI.COMM_WORLD.Get_size() > 1
Returns ``True`` if the `mpi4py` package is installed and MPI returns a world size greater than 1.
src/lightning/fabric/plugins/environments/mpi.py