Hi,
There are many ways to deal with this situation and actually this is an area of research. So, generally, here are few options you can select:

Using sampling in the way that in each batch, same size of classes exists.
How to handle imbalanced classes 8

Weighting loss function in way that biased toward rare class. How to handle imbalanced classes 8

Using ensemble of ANNs using Boosting approaches for generating synthesized data or sampling not biased data such as RBBoost, SMOTEBoost.

There are other ways for sure which you need to find which one suits your case the best.
Bests