code: def cjald(func, X):
      """cjald = Computes Jacobian Along Last Dimension
      Recursively splits tensor ``X`` along its leading dimensions until we are
      left with a vector, computes the jacobian of this vector under the
      transformation ``func``, then stitches all the results back together using
      ``torch.stack``.
      """
      assert X.ndim >= 1
      if X.ndim == 1:
          return jacobian(func, X)
      else:
          return torch.stack(
              [cjald(func, X[i]) for i in range(X.shape[0])], dim=0
          )
  
file_path: pyro/tests/distributions/test_ordered_logistic.py
imports: import pytest
  import torch
  from torch.autograd.functional import jacobian
  from pyro.distributions import Normal, OrderedLogistic
  from pyro.distributions.transforms import OrderedTransform
label_desc: Use image node_id 7 for calling a global function with example usage: cjald(func, X) and returns: jacobian, torch