code: def __init__(
      self,
      doc,
      batch_size,
      args,
      pretrain,
      vocab=None,
      evaluation=False,
      sort_during_eval=False,
      min_length_to_batch_separately=None,
      bert_tokenizer=None,
  ):
      self.batch_size = batch_size
      self.min_length_to_batch_separately = (
          min_length_to_batch_separately
      )
      self.args = args
      self.eval = evaluation
      self.shuffled = not self.eval
      self.sort_during_eval = sort_during_eval
      self.doc = doc
      data = self.load_doc(doc)
  
      # handle vocab
      if vocab is None:
          self.vocab = self.init_vocab(data)
      else:
          self.vocab = vocab
  
      # filter out the long sentences if bert is used
      if self.args.get("bert_model", None):
          data = filter_data(
              self.args["bert_model"], data, bert_tokenizer
          )
  
      # handle pretrain; pretrain vocab is used when args['pretrain'] == True and pretrain is not None
      self.pretrain_vocab = None
      if pretrain is not None and args["pretrain"]:
          self.pretrain_vocab = pretrain.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, self.pretrain_vocab, args
      )
      # shuffle for training
      if self.shuffled:
          random.shuffle(data)
      self.num_examples = len(data)
  
      # chunk into batches
      self.data = self.chunk_batches(data)
      logger.debug("{} batches created.".format(len(self.data)))
  
imports: import random
  import logging
  import torch
  from stanza.models.common.bert_embedding import filter_data
  from stanza.models.common.data import map_to_ids, get_long_tensor, get_float_tensor, sort_all
  from stanza.models.common.vocab import PAD_ID, VOCAB_PREFIX, ROOT_ID, CompositeVocab, CharVocab
  from stanza.models.pos.vocab import WordVocab, XPOSVocab, FeatureVocab, MultiVocab
  from stanza.models.pos.xpos_vocab_factory import xpos_vocab_factory
  from stanza.models.common.doc import *
label_desc: Use image node_id 1 to create a new DataLoader object  with example: obj = DataLoader(doc, batch_size, args, pretrain, vocab, evaluation, sort_during_eval, min_length_to_batch_separately, bert_tokenizer)