I tried that as well, but it results in the same error:
 list_of_attention_val = []
 for i in range(seq):
   association = torch.mv(hidden_states_other[l], hidden_states[i])
   probs = torch.nn.functional.softmax(association)

   attention_val = torch.mv(torch.t(hidden_states_other[l]), probs)
   list_of_attention_val.append(attention_val)
 hidden_states_weights = torch.stack(list_of_attention_val)