Optimal modularity and memory capacity of neural reservoirs