title: How to perform element-wise product in PyTorch?
body: <p>I have two torch tensors a and b. Tensor a has the shape of [batch_size, emb_size] and Tensor b has the shape of [num_of_words, emb_size]. I want to do the element-wise product on these two tensors instead of dot product.</p>
  
  <p>I noticed that "*" can perform element-wise product but it doesn't fit my case.</p>
  
  <p>For example, batch_size = 3, emb_size = 2, num_of_words = 5.</p>
  
  <pre class="lang-py prettyprint-override"><code>a = torch.rand((3,2))
  b = torch.rand((5,2))
  </code></pre>
  
  <p>I want to get something like:</p>
  
  <pre class="lang-py prettyprint-override"><code>torch.cat([a[0]*b, a[1]*b, a[2]*b]).view(3, 5, 2)
  </code></pre>
  
  <p>but I want to do this in an efficient and elegant way.</p>