I’m not sure to understand the posted code correctly, but based on your description I assume you would like to apply different rotation matrices on input tensors?
I’ve written a manual rotation some time ago here 60. Would this be helpful as a starter or are you looking for something else?