import torch


def backprop_jacobian(fn: torch.nn.Module, x: torch.Tensor) -> torch.Tensor:
    """
    Calculate the jacobian of the function w.r.t. the given input tensor x using regular backprop.
    """
    x.requires_grad_()
    batch = x[None]
    return torch.autograd.grad(fn(batch), batch, allow_unused=True)[0][0]