While training rasa-nlu I was getting ResourceExhaustedError. So I used fixed batch size. But as I will have variable sized datasets, I need to know how to calculate the largest possible batch size for any given datasets. Is there any way to do that?

I know that maximum batch size can be calculated using the formula:

Max batch size= available GPU memory bytes / 4 / (size of tensors + trainable parameters)

How do I get the tensor size and the number of trainable parameters?