title: How can I remove "for loop iteration" by using torch tensor operator?
body: <p>I want to get rid of &quot;for loop iteration&quot; by using Pytorch functions in my code. But the formula is complicated and I can't find a clue. Can the &quot;for loop iteration&quot; in the below replaced with the Torch operation?</p>
  <pre class="lang-py prettyprint-override"><code>B=10
  L=20
  H=5
  
  mat_A=torch.randn(B,L,L,H)
  mat_B=torch.randn(L,B,B,H)
  tmp_B=torch.zeros_like(mat_B)
  
  for x in range(L):
      for y in range(B):
          for z in range(B):
              tmp_B[:,y,z,:]+=mat_B[x,y,z,:]*mat_A[z,x,:,:]
  </code></pre>