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: * `create_new_history` creates a new empty history
  * `epochs` is the number of iterations to train on $T$
  * `n_players` is the number of players
docstr_tok: ["*","`","create_new_history","`","creates","a","new","empty","history","*","`","epochs","`","is","the","number","of","iterations","to","train","on","$","T","$","*","`","n_players","`","is","the","number","of","players"]
code: def __init__(
      self,
      *,
      create_new_history: Callable[[], History],
      epochs: int,
      n_players: int = 2,
  ):
      """
      * `create_new_history` creates a new empty history
      * `epochs` is the number of iterations to train on $T$
      * `n_players` is the number of players
      """
      self.n_players = n_players
      self.epochs = epochs
      self.create_new_history = create_new_history
      # A dictionary for $\mathcal{I}$ set of all information sets
      self.info_sets = {}
      # Tracker for analytics
      self.tracker = InfoSetTracker()
  
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 1 to create a new CFR object  with example: obj = CFR()