I use a quick snippet to get the class distribution and pass that into the class weights.
from sklearn.utils import class_weight
class_weights = dict(enumerate(class_weight.compute_class_weight('balanced',
                                                         classes=np.unique(outputs),
                                                         y=outputs)))


history = nlp_model.fit( x_train, y_train, 
                                     batch_size=self.batch_size, 
                                     epochs=epochs,
                                     class_weight=class_weights,
                                     callbacks=self.callbacks,
                                     shuffle=True,
                                     validation_data = (x_test, y_test))