code: def test_arbitrary_dimension_grad(dim):
      shape = [3, 4, 2, 5]
  
      alpha_shape = shape
      alpha_shape[dim] = 1
  
      f = partial(entmax_bisect, dim=dim)
  
      X = torch.randn(*shape, dtype=torch.float64, requires_grad=True)
      alphas = 0.05 + 2.5 * torch.rand(
          alpha_shape, dtype=torch.float64, requires_grad=True
      )
      gradcheck(f, (X, alphas), eps=1e-5)
  
file_path: ludwig/tests/ludwig/utils/entmax/test_root_finding.py
imports: from functools import partial
  from itertools import product
  import pytest
  import torch
  from torch.autograd import gradcheck
  from ludwig.utils.entmax.activations import entmax15, sparsemax
  from ludwig.utils.entmax.root_finding import entmax_bisect, sparsemax_bisect
label_desc: Use image node_id 8 for calling a global function with example usage: test_arbitrary_dimension_grad(dim) without return types