code: def forward(cls, ctx, X, dim=-1, k=None):
      ctx.dim = dim
      max_val, _ = X.max(dim=dim, keepdim=True)
      X = X - max_val  # same numerical stability trick as softmax
      tau, supp_size = _sparsemax_threshold_and_support(X, dim=dim, k=k)
      output = torch.clamp(X - tau, min=0)
      ctx.save_for_backward(supp_size, output)
      return output
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from torch.autograd import Function
  from torch.jit import script
label_desc: Use image node_id 1 for calling the SparsemaxFunction obj's underlying member method code with example usage: obj.forward(cls, ctx, X, dim, k) and returns: output