parameters: (self, random, dist, anneal_steps, payoff_matrices,
                        num_players, temperature=0., proj_grad=True)
return_statement: return (grad_dist, None), unreg_exp, reg_exp
docstring: Computes exploitablity gradient and aux variable gradients with samples.
  
      This implementation takes payoff_matrices as input so technically uses
      O(d^2) compute but only a single column of payoff_matrices is used to
      perform the update so can be re-implemented in O(d) if needed.
  
      Args:
        random: random number generator, np.random.RandomState(seed)
        dist: 1-d np.array, current estimate of nash distribution
        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, anneal_steps) as tuple
        unregularized exploitability (stochastic estimate)
        tsallis regularized exploitability (stochastic estimate)
docstring_summary: Computes exploitablity gradient and aux variable gradients with samples.
docstring_tokens: Computes exploitablity gradient and aux variable gradients with samples .
function: def cheap_gradients(self, random, dist, anneal_steps, payoff_matrices,
                        num_players, temperature=0., proj_grad=True):
      """Computes exploitablity gradient and aux variable gradients with samples.
  
      This implementation takes payoff_matrices as input so technically uses
      O(d^2) compute but only a single column of payoff_matrices is used to
      perform the update so can be re-implemented in O(d) if needed.
  
      Args:
        random: random number generator, np.random.RandomState(seed)
        dist: 1-d np.array, current estimate of nash distribution
        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, anneal_steps) as tuple
        unregularized exploitability (stochastic estimate)
        tsallis regularized exploitability (stochastic estimate)
      """
      del anneal_steps
      action_1 = random.choice(dist.size, p=dist)
      y = nabla = payoff_matrices[0][:, action_1]
      if temperature >= 1e-3:
        br = special.softmax(y / temperature)
        br_mat = (np.diag(br) - np.outer(br, br)) / temperature
        br_policy_gradient = nabla - temperature * (np.log(br) + 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 = nabla - temperature * (np.log(dist) + 1)
      other_player_fx = (br - dist) + br_mat.dot(br_policy_gradient)
  
      action_u = random.choice(dist.size)  # uniform, ~importance sampling
      other_player_fx = dist.size * other_player_fx[action_u]
      other_player_fx_translat = payoff_matrices[1, :, action_u] * other_player_fx
      grad_dist = -policy_gradient + (num_players - 1) * other_player_fx_translat
      if proj_grad:
        grad_dist = simplex.project_grad(grad_dist)
  
      return (grad_dist, None), unreg_exp, reg_exp
function_tokens: def cheap_gradients ( self , random , dist , anneal_steps , payoff_matrices , num_players , temperature = 0. , proj_grad = True ) : del anneal_steps action_1 = random . choice ( dist . size , p = dist ) y = nabla = payoff_matrices [ 0 ] [ : , action_1 ] if temperature >= 1e-3 : br = special . softmax ( y / temperature ) br_mat = ( np . diag ( br ) - np . outer ( br , br ) ) / temperature br_policy_gradient = nabla - temperature * ( np . log ( br ) + 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 = nabla - temperature * ( np . log ( dist ) + 1 ) other_player_fx = ( br - dist ) + br_mat . dot ( br_policy_gradient ) action_u = random . choice ( dist . size ) # uniform, ~importance sampling other_player_fx = dist . size * other_player_fx [ action_u ] other_player_fx_translat = payoff_matrices [ 1 , : , action_u ] * other_player_fx grad_dist = - policy_gradient + ( num_players - 1 ) * other_player_fx_translat if proj_grad : grad_dist = simplex . project_grad ( grad_dist ) return ( grad_dist , None ) , unreg_exp , reg_exp