code: def stratify(examples, strata_field):
      # The field has to be hashable otherwise this doesn't work
      # There's two iterations over the whole dataset here, which can be
      # reduced to just one if a dedicated method for stratified splitting is used
      unique_strata = {
          getattr(example, strata_field) for example in examples
      }
      strata_maps = {s: [] for s in unique_strata}
      for example in examples:
          strata_maps[getattr(example, strata_field)].append(example)
      return list(strata_maps.values())
  
imports: import csv
  import gzip
  import io
  import os
  import shutil
  import tarfile
  import zipfile
  from functools import partial
  import torch.utils.data
  from torchtext.data.utils import RandomShuffler
  from torchtext.utils import download_from_url
  from .example import Example
label_desc: Use image node_id 2 for calling a global function with example usage: stratify(examples, strata_field) and returns: list