Application of simulation-based inference to problems in astrophysics