In my code, I changed torch.bfloat16 to torch.float32, it works.
torch.bfloat16
torch.float32
I'm unsure if this's helpful for you.