Reigning champion Francesco Bagnaia has claimed victory in the Japanese Grand Prix sprint after leader Pedro Acosta crashed out with just four laps to go.