class_docstr: The International Corpus of English (ICE).
  
  NOTE: This text cannot be downloaded
  automatically. You must extract each subset zip file into /benchmark_output/scenarios/ice.
  The archives should extract into folders named according to the dictionary SUBSET_TO_DIRECTORY
  below.
  
  The ICE corpus gathers written and spoken texts from variants of English across 13
  regional subsets:
  Canada, East Africa (Kenya & Tanzania), Great Britain, Hong Kong, India, Ireland,
  Jamaica, Nigeria, New Zealand, the Philippines, Singapore, Sri Lanka, and the United States.
  We evaluate on per-text perplexity (by default, all texts from all regions, but
  can be filtered using scenario parameters).
  
  Initially, we are only able to evaluate the Canada (can), Hong Kong (hk), India (ind), Jamaica (ja),
  Philippines (phi), Singapore (sin) and United States (usa) subsets, as these are the
  only subsets which standardize the organization of their data/metadata. Evaluation
  can be restricted to one of these subsets by passing the corresponding code (parenthesized above)
  into the subset parameter.
  
  Spoken texts are transcripts of conversations, speeches or radio/television programs,
  while written texts range over essays, emails, news reports and other professional
  written material. The corpus is marked up with XML-style annotations which we have
  chosen to eliminate (save for the speaker annotations in the spoken texts).
  
  Here is a spoken text example (from ICE India):
  
  ```
  <|endoftext|><$A>
  
  He says one minute
  
  
  About that uh mm letter sir
  
  
  About uh that letter
  
  
  Board of studies letter
  
  <$B>
  
  I gave it you no
  ...
  ```
  
  Here is a written text example (from ICE-USA):
  
  ```
  <|endoftext|>The U.S. Mint:
  
  
  
    United States coins are made at four Mint facilities:
  
  Philadelphia, Denver, San Francisco, and West Point, NY.
   One easy way to start your collection is with the circulating coins
  
  you use daily - pennies, nickels, dimes, quarters and dollars.
   In addition, the U.S. Mint also issues annual proof and uncirculated
  ...
  ```
  
  Each subset contains exactly 500 texts and maintains a standardized distribution across categories.
  One notable exception to this distribution is the USA subset, for which the spoken texts
  are not present. Evaluation can be restricted to written or spoken texts by passing
  "written" or "spoken" respectively to the split parameter.
  
  Some subsets record metadata of the author(s)/speaker(s) of each text. Currently,
  CAN, HK, IND, USA support filtering texts by gender (gender=M for male, F for female).
  Where there are multiple authors/speakers, a text is only included if all the authors/speakers
  are identified with a single gender. We plan to add support for metadata filtering in PHI,
  as well as filtering by speaker age groups.
  
  Further documentation is provided at https://www.ice-corpora.uzh.ch/en.html
code: def get_instances(
      self, debug_cap: Union[int, None] = None
  ) -> List[Instance]:
      instances: List[Instance] = []
  
      for subset in self.subset:
          # Currently there is no infrastructure in place to unzip files with passwords
          # (the HTTP requests for the data itself also requires some authorization);
          # therefore we can only assume data is already downloaded and extracted
          data_path: str = os.path.join(
              "restricted", self.name, SUBSET_TO_DIRECTORY[subset]
          )
          if not os.path.exists(data_path):
              raise FileNotFoundError(
                  f"Data does not exist at the required location. \
                          Please extract the relevant subset into {data_path}."
              )
  
          corpus_contents = os.listdir(data_path)
  
          if "Corpus" in corpus_contents:
              corpus_name = "Corpus"
          elif "CORPUS" in corpus_contents:
              corpus_name = "CORPUS"
          elif subset == ICESubset.IRELAND:
              corpus_name = "ICE combined running txt"
          elif subset == ICESubset.EAST_AFRICA:
              corpus_name = "all east africa"
          else:
              corpus_name = "corpus"
  
          corpus_path = os.path.join(data_path, corpus_name)
  
          can_filter = (
              subset in list(METADATA_FORMAT.keys()) and self.gender
          )
          selected_texts = (
              self.filter_by_metadata(
                  subset,
                  os.path.join(data_path, "Headers"),
                  listdir_with_pinned_file_order(
                      self.output_path, corpus_path
                  ),
              )
              if can_filter
              else listdir_with_pinned_file_order(
                  self.output_path, corpus_path
              )
          )
  
          for filename in selected_texts:
              if not self.validate_category(subset, filename):
                  continue
  
              try:
                  with open(
                      os.path.join(corpus_path, filename), "r"
                  ) as f:
                      text = f.read()
              except UnicodeDecodeError:
                  with open(
                      os.path.join(corpus_path, filename),
                      "r",
                      encoding="iso-8859-1",
                  ) as f:
                      text = f.read()
  
              preprocessed_texts: List[str]
              if subset == ICESubset.EAST_AFRICA:
                  texts: List[str] = re.split(
                      "[WS]\\d[A-F]\\d{3}[A-Z]*[KT]\n", text
                  )
                  preprocessed_texts = [
                      self.preprocess_text(t, KEEP_TAGS)
                      for t in texts
                      if len(t) > 0
                  ]
              else:
                  preprocessed_texts = [
                      self.preprocess_text(text, KEEP_TAGS)
                  ]
  
              for t in preprocessed_texts:
                  instances.append(
                      Instance(
                          Input(text=t), references=[], split=TEST_SPLIT
                      )
                  )
  
                  if debug_cap and len(instances) >= debug_cap:
                      return instances
  
      return instances
  
imports: import os
  import re
  from typing import List, Union
  from enum import Enum
  import pandas
  from .ice_scenario_pinned_file_order import listdir_with_pinned_file_order
  from .scenario import Scenario, Instance, TEST_SPLIT, Input
label_desc: Use image node_id 5 for calling the ICEScenario obj's underlying member method code with example usage: obj.get_instances(debug_cap) and returns: instances, instances