While taking inspiration from the tensorflow.js Handwritten digit recognition with CNNs tutorial, I stumbled upon the following implementation of the nextBatch function in mnist_data.js: I understood the point of this function was selecting the images and the corresponding label. The problem with the provided…