class_docstr: An implementation of sparsemax (Martins & Astudillo, 2016). See
  :cite:`DBLP:journals/corr/MartinsA16` for detailed description.
  By Ben Peters and Vlad Niculae
docstr: Sparsemax building block: compute the threshold
  
  Parameters
  ----------
  input: torch.Tensor
      any dimension
  dim : int
      dimension along which to apply the sparsemax
  
  Returns
  -------
  tau : torch.Tensor
      the threshold value
  support_size : torch.Tensor
docstr_tok: ["Sparsemax","building","block",":","compute","the","threshold","Parameters","--","--","--","--","--","input",":","torch.Tensor","any","dimension","dim",":","int","dimension","along","which","to","apply","the","sparsemax","Returns","--","--","--","-","tau",":","torch.Tensor","the","threshold","value","support_size",":","torch.Tensor"]
code: def _threshold_and_support(input, dim=-1):
      """Sparsemax building block: compute the threshold
  
      Parameters
      ----------
      input: torch.Tensor
          any dimension
      dim : int
          dimension along which to apply the sparsemax
  
      Returns
      -------
      tau : torch.Tensor
          the threshold value
      support_size : torch.Tensor
  
      """
  
      input_srt, _ = torch.sort(input, descending=True, dim=dim)
      input_cumsum = input_srt.cumsum(dim) - 1
      rhos = _make_ix_like(input, dim)
      support = rhos * input_srt > input_cumsum
  
      support_size = support.sum(dim=dim).unsqueeze(dim)
      tau = input_cumsum.gather(dim, support_size - 1)
      tau /= support_size.to(input.dtype)
      return tau, support_size
  
imports: from torch import nn
  from torch.autograd import Function
  import torch.nn.functional
  import torch
label_desc: Use image node_id 3 for calling the SparsemaxFunction obj's underlying member method code with example usage: obj._threshold_and_support(input, dim) and returns: tau,  support_size