I am looking for a way to perform operations on the following two structures efficiently:

I have a tensor of size (32, 40, 7). I also have a list of list of tensors with the outer list of length 32 and each inner list of length 40. Within the inner list, it has a tensor of (n, 7) where n can be different for each inner list.

For each (1, 1, 7) vector in the (32, 40, 7), I would like to perform certain operations with its corresponding (n, 7) tensor (e.g. let’s say dot product to each row).

What would be an efficient way to do that? Right now I am simply looping over the tensor which is highly inefficient. Sorry if I miss any obvious solution to this and thank you very much for your help in advance