A machine learning framework for solving high-dimensional mean field game and mean field control problems