class_docstr: Wikipedia gender.
class_docstr_tok: ["Wikipedia","gender","."]
docstr: [Abstract] Given the chunk index, load examples from that chunk.
  
  Return a list of tuples. The function `_create_message` will take these tuples
  to form the Message object that is returned by the teacher.
docstr_tok: ["[","Abstract","]","Given","the","chunk","index",",","load","examples","from","that","chunk",".","Return","a","list","of","tuples",".","The","function","`","_create_message","`","will","take","these","tuples","to","form","the","Message","object","that","is","returned","by","the","teacher","."]
code: def load_from_chunk(self, chunk_idx: int):
      """
      [Abstract] Given the chunk index, load examples from that chunk.
  
      Return a list of tuples. The function `_create_message` will take these tuples
      to form the Message object that is returned by the teacher.
      """
      output = []
      chunk_path = self.chunk_idx_to_file[chunk_idx]
  
      extra_data = []
      with open(chunk_path) as wf:
          for article_json in wf:
              article = json.loads(article_json)
              title = article["title"]
              text = article["text"]
  
              title = title.split(" (")[0]
              is_person = check_if_person(title)
              if not is_person:
                  continue
  
              gender = get_gender(text)
  
              label = f"ABOUT:{gender}"
              for par in text.split("\n"):
                  if par:
                      output.append(
                          (par, title, label, gender, "about")
                      )
                      self.counts[gender] += 1
  
                      if self.add_unknown_classes:
                          extra_data.append(
                              (
                                  par,
                                  title,
                                  f"SELF:{gend_utils.UNKNOWN}",
                                  gender,
                                  "self",
                              )
                          )
                          extra_data.append(
                              (
                                  par,
                                  title,
                                  f"PARTNER:{gend_utils.NEUTRAL}",
                                  gender,
                                  "partner",
                              )
                          )
  
      if len(extra_data) > 0:
          # possibly sample unknown classes
          sample_rate = self.opt["unknown_temp"]
          if sample_rate < 1.0:
              to_samp = int(sample_rate * len(extra_data))
              sampled = random.sample(extra_data, to_samp)
              output += sampled
          else:
              output += extra_data
  
      if DEBUG:
          print("\n\nGender count update:")
          for k, v in self.counts.items():
              print(f"{k}: {v}")
  
      if (self.is_train and self.opt["balance"]) or (
          self.is_valid and self.opt["balance_valid"]
      ):
          exclude_lst = [
              f"ABOUT:{gend_utils.NONBINARY}",
              f"SELF:{gend_utils.UNKNOWN}",
              f"PARTNER:{gend_utils.NEUTRAL}",
          ]  # not enough of each of these examples to balance
          output = gend_utils.balance_data(
              output, key=2, exclude_labels=exclude_lst
          )
  
      if len(output) == 0:
          warn_once(f"CHUNK {chunk_idx} is empty")
  
      return output
  
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 ChunkTeacher
  from parlai.tasks.wikipedia.build import build
  from parlai.utils.misc import warn_once
  import parlai.tasks.md_gender.utils
  from copy import deepcopy
  import json
  import os
  import random
  import re
  import spacy
  from typing import List
label_desc: Use image node_id 7 for calling the WikipediaTeacher obj's underlying member method code with example usage: obj.load_from_chunk(chunk_idx) and returns: output