As I know Gradient Descent has three variants which are:

1- Batch Gradient Descent: processes all the training examples for each iteration of gradient descent.

2- Stochastic Gradient Descent: processes 1 training example per iteration. Hence, the parameters are being updated even after one iteration in which only a single example has been processed.

3- Mini Batch gradient descent: which works faster than both batch gradient descent and stochastic gradient descent. Here b examples where b

But in some cases they use Stochastic Gradient Descent and they define a batch size for training, I am confused about that?

But in some cases they use Stochastic Gradient Descent and they define a batch size for training, I am confused about that?

If you defining a batch size, then you are performing mini-batch gradient descent.

Stochastic Gradient Descent ( SGD ) and Mini Batch Gradient Descent are often used interchangeably in many places. The idea is that if the batch size is 1, then its totally SGD.

If the batch size is equal to the number of samples in the dataset, then its Batch Gradient Descent.