For example, tensors shape:T1： NxCxTxV, T2： VxV; I want use T2 to  linear combination the value in last dimension of T1, get out：NxCxTxV. I completed one to clarify my problem in the following, but is there any more simple way in pytorch to do it?
N, C, T, V = 2,2,3,2
tensor1 = torch.randn(N, C, T, V )
tensor2 = torch.randn(V,V)
temp = tensor1.contiguous().view(N*C*T,V)
temp2 = torch.empty_like(temp)
for i in range(N*C*T):
    temp2[i] = torch.matmul(tensor2,temp[i])
    
out = temp2.contiguous().view(N,C,T,V)
# test
torch.matmul(tensor2,tensor1[0,0,0,:],)==out[0,0,0,:]