Batch size is the number of datapoints you forward pass at once and compute the gradients for. I am not sure I understand your question. Could you rephrase it? According to the error, the number of images and  target labels must be same for calculating the loss