class_docstr: ALL LIGHT Teacher: combines all gender bias mitigation methods described in.
  
  <https://arxiv.org/abs/1911.03842>.
  
  This teacher combines methods for gender bias mitigation in
  dialogue generation on the LIGHT dialogue task, including:
  - Adding more positive data (Pos Data):`--add-new-data`
  - Conditional training (Bias Ctrl): `--add-conditional`
  - Counterfactual Data Augmentation (CDA): `--add-counterfactual`
  
  For more information, please see our projects page:
  <https://parl.ai/projects/genderation_bias/>
class_docstr_tok: ["ALL","LIGHT","Teacher",":","combines","all","gender","bias","mitigation","methods","described","in",".","<","https",":","\/\/arxiv.org\/abs\/1911.03842",">",".","This","teacher","combines","methods","for","gender","bias","mitigation","in","dialogue","generation","on","the","LIGHT","dialogue","task",",","including",":","-","Adding","more","positive","data","(","Pos","Data",")",":","`","--","add-new-data","`","-","Conditional","training","(","Bias","Ctrl",")",":","`","--","add-conditional","`","-","Counterfactual","Data","Augmentation","(","CDA",")",":","`","--","add-counterfactual","`","For","more","information",",","please","see","our","projects","page",":","<","https",":","\/\/parl.ai\/projects\/genderation_bias\/",">"]
docstr: Return the counterfactual example for a given example (i.e. swap 'he' --> 'she')
docstr_tok: ["Return","the","counterfactual","example","for","a","given","example","(","i.e",".","swap","'he","'","--",">","'she","'",")"]
code: def _flip_ex(self, ex):
      """
      Return the counterfactual example for a given example (i.e. swap 'he' --> 'she')
      """
      new_ex = deepcopy(ex)
      text = ex["text"]
      labels = "labels" if "labels" in ex else "eval_labels"
      label = ex[labels][0]
      new_ex.force_set("text", self._flip_str(text))
      new_ex.force_set(labels, [self._flip_str(label)])
      return new_ex
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.message import Message
  from parlai.core.teachers import FixedDialogTeacher
  from parlai.tasks.light_dialog.agents import DefaultTeacher
  from parlai.tasks.light_genderation_bias.build import build
  from parlai.utils.io import PathManager
  from collections import deque
  from copy import deepcopy
  import csv
  import json
  import os
  import random
label_desc: Use image node_id 7 for calling the LightGenderTeacher obj's underlying member method code with example usage: obj._flip_ex(ex) and returns: new_ex