code: def test_loss(Loss, ignore_index, reduction):
      for X, y in zip(Xs, ys):
          iix = y[0] if ignore_index else -100
          ls = Loss(ignore_index=iix, reduction=reduction)
          gradcheck(ls, (X, y), eps=1e-5)
  
file_path: ludwig/tests/ludwig/utils/entmax/test_losses.py
imports: from functools import partial
  import pytest
  import torch
  from torch.autograd import gradcheck
  from ludwig.constants import IGNORE_INDEX_TOKEN_ID
  from ludwig.utils.entmax.losses import Entmax15Loss, EntmaxBisectLoss, SparsemaxBisectLoss, SparsemaxLoss
label_desc: Use image node_id 2 for calling a global function with example usage: test_loss(Loss, ignore_index, reduction) without return types