docstr: alpha-entmax: normalizing sparse map (a la softmax) via bisection.
  
  Solves the optimization problem:
  
      max_p <x, p> - H_a(p)    s.t.    p >= 0, sum(p) == 1.
  
  where H_a(p) is the Tsallis alpha-entropy with custom alpha >= 1,
  using a bisection (root finding, binary search) algorithm.
  
  Parameters
  ----------
  alpha : float or torch.Tensor
      Tensor of alpha parameters (> 1) to use. If scalar
      or python float, the same value is used for all rows, otherwise,
      it must have shape (or be expandable to)
      alpha.shape[j] == (X.shape[j] if j != dim else 1)
      A value of alpha=2 corresponds to sparsemax; and alpha=1 would in theory recover
      softmax. For numeric reasons, this algorithm does not work with `alpha=1`; if you
      want softmax, we recommend `torch.nn.softmax`.
  
  dim : int
      The dimension along which to apply alpha-entmax.
  
  n_iter : int
      Number of bisection iterations. For float32, 24 iterations should
      suffice for machine precision.
docstr_tok: ["alpha-entmax",":","normalizing","sparse","map","(","a","la","softmax",")","via","bisection",".","Solves","the","optimization","problem",":","max_p","<","x",",","p",">","-","H_a","(","p",")","s.t",".","p",">","=","0",",","sum","(","p",")","==","1.","where","H_a","(","p",")","is","the","Tsallis","alpha-entropy","with","custom","alpha",">","=","1",",","using","a","bisection","(","root","finding",",","binary","search",")","algorithm",".","Parameters","--","--","--","--","--","alpha",":","float","or","torch.Tensor","Tensor","of","alpha","parameters","(",">","1",")","to","use",".","If","scalar","or","python","float",",","the","same","value","is","used","for","all","rows",",","otherwise",",","it","must","have","shape","(","or","be","expandable","to",")","alpha.shape","[","j","]","==","(","X.shape","[","j","]","if","j","!","=","dim","else","1",")","A","value","of","alpha=2","corresponds","to","sparsemax",";","and","alpha=1","would","in","theory","recover","softmax",".","For","numeric","reasons",",","this","algorithm","does","not","work","with","`","alpha=1","`",";","if","you","want","softmax",",","we","recommend","`","torch.nn.softmax","`",".","dim",":","int","The","dimension","along","which","to","apply","alpha-entmax",".","n_iter",":","int","Number","of","bisection","iterations",".","For","float32",",","24","iterations","should","suffice","for","machine","precision","."]
code: def __init__(self, alpha=1.5, dim=-1, n_iter=50):
      """alpha-entmax: normalizing sparse map (a la softmax) via bisection.
  
      Solves the optimization problem:
  
          max_p <x, p> - H_a(p)    s.t.    p >= 0, sum(p) == 1.
  
      where H_a(p) is the Tsallis alpha-entropy with custom alpha >= 1,
      using a bisection (root finding, binary search) algorithm.
  
      Parameters
      ----------
      alpha : float or torch.Tensor
          Tensor of alpha parameters (> 1) to use. If scalar
          or python float, the same value is used for all rows, otherwise,
          it must have shape (or be expandable to)
          alpha.shape[j] == (X.shape[j] if j != dim else 1)
          A value of alpha=2 corresponds to sparsemax; and alpha=1 would in theory recover
          softmax. For numeric reasons, this algorithm does not work with `alpha=1`; if you
          want softmax, we recommend `torch.nn.softmax`.
  
      dim : int
          The dimension along which to apply alpha-entmax.
  
      n_iter : int
          Number of bisection iterations. For float32, 24 iterations should
          suffice for machine precision.
  
      """
      self.dim = dim
      self.n_iter = n_iter
      self.alpha = alpha
      super().__init__()
  
imports: import torch
  import torch.nn
  from torch.autograd import Function
label_desc: Use image node_id 1 to create a new EntmaxBisect object from inherited base classes: nn with example: obj = EntmaxBisect(alpha, dim, n_iter)