code: def get_essentials(train_df, max_seq_length=128, train_batch_size=16):
      X, y = train_df.iloc[:, 0].values, train_df.iloc[:, 1].values
  
      text_field = data.Field()
      text_field.build_vocab(X, max_size=10000)
  
      X_split = [t.split() for t in X]
  
      # pad
      X_pad = [pad(s, max_seq_length) for s in X_split]
  
      # to index
      X_index = [to_indexes(text_field.vocab, s) for s in X_pad]
  
      train_dataset = to_dataset(X_index, y)
  
      train_sampler = SequentialSampler(train_dataset)
      train_loader = DataLoader(
          train_dataset,
          sampler=train_sampler,
          batch_size=train_batch_size,
          drop_last=True,
      )
  
      return text_field, train_loader
  
imports: from __future__ import print_function, unicode_literals
  import random
  from contextlib import closing
  from multiprocessing import Pool
  import numpy
  import pandas
  import torch
  from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset, random_split
  from torchtext.legacy import data
  from tqdm import tqdm
label_desc: Use image node_id 9 for calling a global function with example usage: get_essentials(train_df, max_seq_length, train_batch_size) and returns: text_field,  train_loader