code: def sparsemax_bisect(
      X, dim=-1, n_iter=50, ensure_sum_one=True, training=True
  ):
      """sparsemax: normalizing sparse transform (a la softmax), via bisection.
  
      Solves the projection:
  
          min_p ||x - p||_2   s.t.    p >= 0, sum(p) == 1.
  
      Parameters
      ----------
      X : torch.Tensor
          The input tensor.
  
      dim : int
          The dimension along which to apply sparsemax.
  
      n_iter : int
          Number of bisection iterations. For float32, 24 iterations should
          suffice for machine precision.
  
      ensure_sum_one : bool,
          Whether to divide the result by its sum. If false, the result might
          sum to close but not exactly 1, which might cause downstream problems.
  
      Note: This function does not yet support normalizing along anything except
      the last dimension. Please use transposing and views to achieve more
      general behavior.
  
      Returns
      -------
      P : torch tensor, same shape as X
          The projection result, such that P.sum(dim=dim) == 1 elementwise.
      """
      # Avoids call to custom autograd.Function during eval to ensure torchscript compatibility
      # custom autograd.Function is not scriptable: https://github.com/pytorch/pytorch/issues/22329#issuecomment-506608053
      if not training:
          output, _ = _sparsemax_bisect_forward(
              X, dim, n_iter, ensure_sum_one
          )
          return output
      return SparsemaxBisectFunction.apply(
          X, dim, n_iter, ensure_sum_one
      )
  
imports: import torch
  import torch.nn
  from torch.autograd import Function
label_desc: Use image node_id 4 for calling a global function with example usage: sparsemax_bisect(X, dim, n_iter, ensure_sum_one, training) and returns: SparsemaxBisectFunction, output