code: def _jacobian_wrt_parameter(y, param, tape):
      """Computes a Jacobian w.r.t. a parameter."""
      # For input shapes (b, dy), yields shape (b, dy, 1) (1 is added for
      # convenience elsewhere).
      # To avoid having to broadcast param to y's shape, we need to take a forward
      # gradient.
      with tf.GradientTape() as w_tape:
          w = tf.zeros_like(y)
          w_tape.watch(w)
          vjp = tape.gradient(y, param, output_gradients=w)
      if vjp is None:  # Unconnected.
          return tf.expand_dims(tf.zeros_like(y), axis=-1)
      return tf.expand_dims(w_tape.gradient(vjp, w), axis=-1)
  
file_path: tf-quant-finance/tf_quant_finance/math/custom_loops.py
imports: import tensorflow.compat.v2
  from tf_quant_finance import utils
label_desc: Use image node_id 5 for calling a global function with example usage: _jacobian_wrt_parameter(y, param, tape) and returns: tf, tf