class_docstr: ## Counterfactual Regret Minimization (CFR) Algorithm
  
  We do chance sampling (**CS**) where all the chance events (nodes) are sampled and
  all other events (nodes) are explored.
  
  We can ignore the term $q(z)$ since it's the same for all terminal histories
  since we are doing chance sampling and it cancels out when calculating
  strategy (common in numerator and denominator).
class_docstr_tok: ["#","#","Counterfactual","Regret","Minimization","(","CFR",")","Algorithm","We","do","chance","sampling","(","*","*","CS","*","*",")","where","all","the","chance","events","(","nodes",")","are","sampled","and","all","other","events","(","nodes",")","are","explored",".","We","can","ignore","the","term","$","q","(","z",")","$","since","it","'s","the","same","for","all","terminal","histories","since","we","are","doing","chance","sampling","and","it","cancels","out","when","calculating","strategy","(","common","in","numerator","and","denominator",")","."]
docstr: ### Iteratively update $        extcolor{lightgreen}{\sigma^t(I)(a)}$
  
  This updates the strategies for $T$ iterations.
docstr_tok: ["#","#","#","Iteratively","update","$","extcolor","{","lightgreen","}","{","\\sigma^t","(","I",")","(","a",")","}","$","This","updates","the","strategies","for","$","T","$","iterations","."]
code: def iterate(self):
      """
      ### Iteratively update $\textcolor{lightgreen}{\sigma^t(I)(a)}$
  
      This updates the strategies for $T$ iterations.
      """
  
      # Loop for `epochs` times
      for t in monit.iterate("Train", self.epochs):
          # Walk tree and update regrets for each player
          for i in range(self.n_players):
              self.walk_tree(
                  self.create_new_history(), cast(Player, i), 1, 1
              )
  
          # Track data for analytics
          tracker.add_global_step()
          self.tracker(self.info_sets)
          tracker.save()
  
          # Save checkpoints every $1,000$ iterations
          if (t + 1) % 1_000 == 0:
              experiment.save_checkpoint()
  
      # Print the information sets
      logger.inspect(self.info_sets)
  
imports: from typing import NewType, Dict, List, Callable, cast
  from labml import monit, tracker, logger, experiment
  from labml.configs import BaseConfigs, option
label_desc: Use image node_id 4 for calling the CFR obj's underlying member method code with example usage: obj.iterate() without return types