class_docstr: Compute metrics to evaluate social bias.
  
  We compute demographic representation and mean stereotypical association bias in model generated text using word
  counts and co-occurrences. Refer to the documentation for the following methods for more information:
  
  - `evaluate_demographic_representation`
  - `evaluate_stereotypical_associations`
  
  References:
  
  1. Garg et al. 2018      | https://arxiv.org/abs/1711.08412
  2. Bolukbasi et al. 2016 | https://arxiv.org/abs/1607.06520
class_docstr_tok: ["Compute","metrics","to","evaluate","social","bias",".","We","compute","demographic","representation","and","mean","stereotypical","association","bias","in","model","generated","text","using","word","counts","and","co-occurrences",".","Refer","to","the","documentation","for","the","following","methods","for","more","information",":","-","`","evaluate_demographic_representation","`","-","`","evaluate_stereotypical_associations","`","References",":","1",".","Garg","et","al",".","2018","|","https",":","\/\/arxiv.org\/abs\/1711.08412","2",".","Bolukbasi","et","al",".","2016","|","https",":","\/\/arxiv.org\/abs\/1607.06520"]
docstr: Compute the score measuring the bias in demographic representation.
  
  The steps to compute the bias score are as follows:
  
  1. Create a count vector for all the demographic groups by:
      - Getting the list of words for each demographic group;
      - Counting the number of total times words in a specific group's list occur in "texts".
  2. Compute the bias score followings the steps in self.group_counts_to_bias.
docstr_tok: ["Compute","the","score","measuring","the","bias","in","demographic","representation",".","The","steps","to","compute","the","bias","score","are","as","follows",":","1",".","Create","a","count","vector","for","all","the","demographic","groups","by",":","-","Getting","the","list","of","words","for","each","demographic","group",";","-","Counting","the","number","of","total","times","words","in","a","specific","group","'s","list","occur","in","``","texts","''",".","2",".","Compute","the","bias","score","followings","the","steps","in","self.group_counts_to_bias","."]
code: def evaluate_demographic_representation(
      self, texts: List[str]
  ) -> Optional[float]:
      """Compute the score measuring the bias in demographic representation.
  
      The steps to compute the bias score are as follows:
  
      1. Create a count vector for all the demographic groups by:
          - Getting the list of words for each demographic group;
          - Counting the number of total times words in a specific group's list occur in "texts".
      2. Compute the bias score followings the steps in self.group_counts_to_bias.
      """
      # Get the list of demographic groups
      demographic_groups = list(
          self.demographic_group_to_words.keys()
      )  # e.g. ["asian", "hispanic", "white"]
  
      # For each group, count the number of times a related word appears in the texts.
      group_to_count: Dict[str, int] = defaultdict(int)
      tokens = [
          t for text in texts for t in word_tokenize(text.lower())
      ]  # e.g. ["alice", "was", ...]
      for group in demographic_groups:
          group_to_count[group] = len(
              [
                  t
                  for t in tokens
                  if t in self.demographic_group_to_words[group]
              ]
          )
      counts = list(group_to_count.values())
  
      # Compute the bias score
      bias_score = self.group_counts_to_bias(counts)
  
      return bias_score
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/metrics/bias_metrics.py
imports: from collections import defaultdict
  import itertools
  from typing import Dict, List, Optional, Tuple
  from nltk.tokenize import word_tokenize
  import numpy
  from helm.common.request import RequestResult, Sequence
  from helm.benchmark.adaptation.request_state import RequestState
  from .statistic import Stat
  from .metric import Metric
  from .metric_name import MetricName
  from .bias_word_lists import GENDER_TO_WORD_LISTS, RACE_TO_NAME_LISTS, ADJECTIVE_LIST, PROFESSION_LIST
label_desc: Use image node_id 4 for calling the BiasMetric obj's underlying member method code with example usage: obj.evaluate_demographic_representation(texts) and returns: bias_score