parameters: (self, dist, y, anneal_steps, payoff_matrices, num_players,
                  temperature=0., proj_grad=True)
return_statement: return (grad_dist, grad_y, grad_anneal_steps), unreg_exp, reg_exp
docstring: Computes exploitablity gradient and aux variable gradients.
  
      Args:
        dist: 1-d np.array, current estimate of nash distribution
        y: 1-d np.array (same shape as dist), current estimate of payoff gradient
        anneal_steps: int, elapsed num steps since last anneal
        payoff_matrices: (>=2 x A x A) np.array, payoffs for each joint action
        num_players: int, number of players, in case payoff_matrices is
          abbreviated
        temperature: non-negative float, default 0.
        proj_grad: bool, if True, projects dist gradient onto simplex
      Returns:
        gradient of exploitability w.r.t. (dist, y, anneal_steps) as tuple
        unregularized exploitability (stochastic estimate)
        tsallis regularized exploitability (stochastic estimate)
docstring_summary: Computes exploitablity gradient and aux variable gradients.
docstring_tokens: Computes exploitablity gradient and aux variable gradients .
function: def gradients(self, dist, y, anneal_steps, payoff_matrices, num_players,
                  temperature=0., proj_grad=True):
      """Computes exploitablity gradient and aux variable gradients.
  
      Args:
        dist: 1-d np.array, current estimate of nash distribution
        y: 1-d np.array (same shape as dist), current estimate of payoff gradient
        anneal_steps: int, elapsed num steps since last anneal
        payoff_matrices: (>=2 x A x A) np.array, payoffs for each joint action
        num_players: int, number of players, in case payoff_matrices is
          abbreviated
        temperature: non-negative float, default 0.
        proj_grad: bool, if True, projects dist gradient onto simplex
      Returns:
        gradient of exploitability w.r.t. (dist, y, anneal_steps) as tuple
        unregularized exploitability (stochastic estimate)
        tsallis regularized exploitability (stochastic estimate)
      """
      nabla = payoff_matrices[0].dot(dist)
      if temperature >= 1e-3:
        br = special.softmax(y / temperature)
        br_mat = (np.diag(br) - np.outer(br, br)) / temperature
        log_br_safe = np.clip(np.log(br), -1e5, 0)
        br_policy_gradient = nabla - temperature * (log_br_safe + 1)
      else:
        power = np.inf
        s = np.linalg.norm(y, ord=power)
        br = np.zeros_like(dist)
        maxima = (y >= s)
        br[maxima] = 1. / maxima.sum()
        br_mat = np.zeros((br.size, br.size))
        br_policy_gradient = np.zeros_like(br)
  
      unreg_exp = np.max(y) - y.dot(dist)
      entr_br = temperature * special.entr(br).sum()
      entr_dist = temperature * special.entr(dist).sum()
      reg_exp = y.dot(br - dist) + entr_br - entr_dist
  
      policy_gradient = np.array(nabla)
      if temperature > 0:
        log_dist_safe = np.clip(np.log(dist), -1e5, 0)
        policy_gradient -= temperature * (log_dist_safe + 1)
      other_player_fx = (br - dist) + br_mat.dot(br_policy_gradient)
  
      other_player_fx_translated = payoff_matrices[1].dot(other_player_fx)
      grad_dist = -policy_gradient
      grad_dist += (num_players - 1) * other_player_fx_translated
      if proj_grad:
        grad_dist = simplex.project_grad(grad_dist)
      grad_y = y - nabla
  
      _, lr_y = self.lrs
      if (reg_exp < self.exp_thresh) and (anneal_steps >= 1 / lr_y):
        self.temperature = np.clip(temperature / 2., 0., 1.)
        if self.temperature < 1e-3:
          self.temperature = 0.
        grad_anneal_steps = -anneal_steps
      else:
        grad_anneal_steps = 1
  
      return (grad_dist, grad_y, grad_anneal_steps), unreg_exp, reg_exp
function_tokens: def gradients ( self , dist , y , anneal_steps , payoff_matrices , num_players , temperature = 0. , proj_grad = True ) : nabla = payoff_matrices [ 0 ] . dot ( dist ) if temperature >= 1e-3 : br = special . softmax ( y / temperature ) br_mat = ( np . diag ( br ) - np . outer ( br , br ) ) / temperature log_br_safe = np . clip ( np . log ( br ) , - 1e5 , 0 ) br_policy_gradient = nabla - temperature * ( log_br_safe + 1 ) else : power = np . inf s = np . linalg . norm ( y , ord = power ) br = np . zeros_like ( dist ) maxima = ( y >= s ) br [ maxima ] = 1. / maxima . sum ( ) br_mat = np . zeros ( ( br . size , br . size ) ) br_policy_gradient = np . zeros_like ( br ) unreg_exp = np . max ( y ) - y . dot ( dist ) entr_br = temperature * special . entr ( br ) . sum ( ) entr_dist = temperature * special . entr ( dist ) . sum ( ) reg_exp = y . dot ( br - dist ) + entr_br - entr_dist policy_gradient = np . array ( nabla ) if temperature > 0 : log_dist_safe = np . clip ( np . log ( dist ) , - 1e5 , 0 ) policy_gradient -= temperature * ( log_dist_safe + 1 ) other_player_fx = ( br - dist ) + br_mat . dot ( br_policy_gradient ) other_player_fx_translated = payoff_matrices [ 1 ] . dot ( other_player_fx ) grad_dist = - policy_gradient grad_dist += ( num_players - 1 ) * other_player_fx_translated if proj_grad : grad_dist = simplex . project_grad ( grad_dist ) grad_y = y - nabla _ , lr_y = self . lrs if ( reg_exp < self . exp_thresh ) and ( anneal_steps >= 1 / lr_y ) : self . temperature = np . clip ( temperature / 2. , 0. , 1. ) if self . temperature < 1e-3 : self . temperature = 0. grad_anneal_steps = - anneal_steps else : grad_anneal_steps = 1 return ( grad_dist , grad_y , grad_anneal_steps ) , unreg_exp , reg_exp