Using machine learning to measure ultrahigh-flux multi-MeV gamma rays from a laser accelerator