code: def jacobian_sn_mlp_block_bf(
      layers: List[Tuple[mx.gluon.HybridBlock, Tensor]]
  ) -> Tensor:
      """
      Brute force computation of the jacobian of a SNMlpBlock jac is of shape
      (Batch dim1, ..., Output dim, Input dim)
  
      Parameters
      ----------
      layers
          A list of tuples where each tuple (layer, input) is associated to a
          composing layer of the SNMLPBlock, where layer corresponds to the
          associated object layer, along with its input tensor.
  
      Returns
      -------
      Tensor
          Jacobian of the SNMLPBlock computed at a given input
      """
      for i, (layer, input) in enumerate(layers[::-1]):
          if isinstance(layer, SNDense):
              # broadcast weight of size (Output dim, Input dim)
              # to (Batch dim1, ..., Output dim, Input dim)
              jac_t = _broadcast_param(
                  layer.weight,
                  axes=range(len(input.shape[:-1])),
                  sizes=input.shape[:-1],
              )
              if i == 0:
                  jac = jac_t
              else:
                  jac = gemm2(jac, jac_t)
          else:
              # act_deriv is of shape (Batch dim1, ..., Input dim)
              act_deriv = get_activation_deriv(layer)(mx.ndarray, input)
              # to (Batch dim1, ..., Output dim, Input dim) to fit the jacobian
              jac_t = act_deriv.expand_dims(
                  len(jac.shape[:-2])
              ).broadcast_axes(
                  axis=len(jac.shape[:-2]), size=jac.shape[-2]
              )
              jac = jac * jac_t
      return jac
  
file_path: gluonts/src/gluonts/mx/block/snmlp.py
imports: from typing import List, Tuple
  import warnings
  import mxnet
  from mxnet.ndarray import linalg_gemm2
  from gluonts.mx import Tensor
  from gluonts.core.component import validated
  from gluonts.mx.util import _broadcast_param
  from gluonts.mx.activation import get_activation, get_activation_deriv
  from gluonts.mx.block.sndense import SNDense
label_desc: Use image node_id 1 for calling a global function with example usage: jacobian_sn_mlp_block_bf(layers) and returns: jac