code: def test_sparsemax_topk(dim, coef, k):
      x = coef * torch.randn(3, 4, 5)
      tau1, supp1 = _sparsemax_threshold_and_support(x, dim=dim, k=None)
      tau2, supp2 = _sparsemax_threshold_and_support(x, dim=dim, k=k)
  
      assert torch.all(tau1 == tau2)
      assert torch.all(supp1 == supp2)
  
imports: import pytest
  import torch
  from torch.autograd import gradcheck
  from ludwig.utils.entmax.activations import _entmax_threshold_and_support, _sparsemax_threshold_and_support, Entmax15, Sparsemax
label_desc: Use image node_id 3 for calling a global function with example usage: test_sparsemax_topk(dim, coef, k) without return types