title: Tape Gradient with respect to multiple variables
body: <p>I am training a model in eager mode of tensorflow, and I need to calculate gradient with respect to multiple variables, say w1 and w2 , which have different shapes.</p>
  
  <p>I know that using the persistent mode of tf.GradientTape(), I can take the gradient with respect to the variables in turn. However, I want to concatenate the variables and do it all at once:</p>
  
  <pre class="lang-py prettyprint-override"><code>with tf.GradientTape() as tape:
       # build a function of variables w1, w2
       loss = f(w1, w2)
  grad = tape.gradient(loss, [w1,w2])
  </code></pre>
  
  <p>Off course, the above code raises an error for [w1, w2], as their shapes are not compatible.</p>
  
  <p>I am wondering how should I concatenate the variables with different size, so that it works for subsequent applying the gradients?</p>