code: def data_loader(
      fn=None,
      indices=None,
      label=LABEL,
      batch_size=1000,
  ):
      """Returns a generator, yielding two lists containing
      [labels], [text]. Items are always returned in the
      order in the file, regardless if indices are provided."""
  
      def _split_labels_and_text(batch):
          l, t = [
              list(t) for t in zip(*(z.split(" ", 1) for z in batch))
          ]
          return l, t
  
      # Prepare a stack of indices
      if indices is not None:
          stack_indices = sorted(indices, reverse=True)
          stack_idx = stack_indices.pop()
  
      with open(fn, "r") as f:
          len_label = len(label)
          idx = 0
          batch_counter = 0
          prev = f.readline()
          batch = []
          while True:
              try:
                  line = f.readline()
                  line = line
                  if line[:len_label] == label or line == "":
                      if indices is None or stack_idx == idx:
                          # Write out prev line and reset prev
                          batch.append(
                              prev.strip().replace("\n", NEWLINE)
                          )
                          batch_counter += 1
  
                          if indices is not None:
                              if len(stack_indices):
                                  stack_idx = stack_indices.pop()
                              else:  # No more data in indices, quit loading data.
                                  yield _split_labels_and_text(batch)
                                  break
                      prev = ""
                      idx += 1
                      if batch_counter == batch_size:
                          yield _split_labels_and_text(batch)
                          # Reset batch
                          batch_counter = 0
                          batch = []
                  prev += line
                  if line == "":
                      if len(batch) > 0:
                          yield _split_labels_and_text(batch)
                      break
              except EOFError:
                  if indices is None or stack_idx == idx:
                      # Write out prev line and reset prev
                      batch.append(prev.strip().replace("\n", NEWLINE))
                      batch_counter += 1
                      yield _split_labels_and_text(batch)
                  break
  
file_path: cleanlab/cleanlab/models/fasttext.py
imports: import time
  import os
  import copy
  import numpy
  from sklearn.base import BaseEstimator
  from fasttext import train_supervised, load_model
label_desc: Use image node_id 1 for calling a global function with example usage: data_loader(fn, indices, label, batch_size) and returns: l,  t