initialize mpi settings

def initialize_mpi(mpi=False):
        """initialize mpi settings"""
        if mpi:
            import mpi4py.MPI
            comm = mpi4py.MPI.COMM_WORLD
            rank = comm.Get_rank()
            size = comm.Get_size()
        else:
            comm = None
            rank = 0
            size = 1
        return {
            "comm": comm,
            "rank": rank,
            "size": size,
            "mode": mpi
        }