title: PyTorch, apply different functions element-wise
body: <p>I defined a tensor like this</p>
  
  <pre class="lang-py prettyprint-override"><code>t_shape = [4, 1]
  data = torch.rand(t_shape)
  </code></pre>
  
  <p>I want to apply different functions to each row. </p>
  
  <pre class="lang-py prettyprint-override"><code>funcs = [lambda x: x+1, lambda x: x**2, lambda x: x-1, lambda x: x*2]  # each function for each row.
  </code></pre>
  
  <p>I can do it with the following code</p>
  
  <pre class="lang-py prettyprint-override"><code>d = torch.tensor([f(data[i]) for i, f in enumerate(funcs)])
  </code></pre>
  
  <p>How can I do it in a proper way with more advanced APIs defined in PyTorch?</p>