code: def __init__(
      self, doc, batch_size, args, vocab=None, evaluation=False
  ):
      self.batch_size = batch_size
      self.args = args
      self.eval = evaluation
      self.shuffled = not self.eval
      self.doc = doc
  
      data = self.load_doc(self.doc, evaluation=self.eval)
  
      # handle vocab
      if vocab is None:
          self.vocab = self.init_vocab(data)
      else:
          self.vocab = vocab
  
      # filter and sample data
      if args.get("sample_train", 1.0) < 1.0 and not self.eval:
          keep = int(args["sample_train"] * len(data))
          data = random.sample(data, keep)
          logger.debug(
              "Subsample training set with rate {:g}".format(
                  args["sample_train"]
              )
          )
  
      data = self.preprocess(data, self.vocab, args)
      # shuffle for training
      if self.shuffled:
          indices = list(range(len(data)))
          random.shuffle(indices)
          data = [data[i] for i in indices]
      self.num_examples = len(data)
  
      # chunk into batches
      data = [
          data[i : i + batch_size]
          for i in range(0, len(data), batch_size)
      ]
      self.data = data
      logger.debug("{} batches created.".format(len(data)))
  
file_path: stanza/stanza/models/mwt/data.py
imports: import random
  import numpy
  import os
  from collections import Counter
  import logging
  import torch
  import stanza.models.common.seq2seq_constant
  from stanza.models.common.data import map_to_ids, get_long_tensor, get_float_tensor, sort_all
  from stanza.models.mwt.vocab import Vocab
  from stanza.models.common.doc import Document
label_desc: Use image node_id 1 to create a new DataLoader object  with example: obj = DataLoader(doc, batch_size, args, vocab, evaluation)