code: def df_to_bert_format(df, max_length, tokenizer):
      sentences = df.iloc[:, 0].values
      labels = df.iloc[:, 1].values
  
      input_ids = []
      attention_masks = []
  
      for sent in sentences:
          encoded_dict = tokenizer.encode_plus(
              sent,
              add_special_tokens=True,
              max_length=max_length,
              pad_to_max_length=True,
              truncation=True,
              return_attention_mask=True,
              return_tensors="pt",
          )
  
          input_ids.append(encoded_dict["input_ids"])
          attention_masks.append(encoded_dict["attention_mask"])
  
      input_ids = torch.cat(input_ids, dim=0)
      attention_masks = torch.cat(attention_masks, dim=0)
      labels = torch.tensor(labels)
  
      return input_ids, attention_masks, labels
  
file_path: KD_Lib/KD_Lib/KD/text/utils/bert.py
imports: from copy import deepcopy
  import matplotlib.pyplot
  import numpy
  import torch
  from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset, random_split
label_desc: Use image node_id 2 for calling a global function with example usage: df_to_bert_format(df, max_length, tokenizer) and returns: input_ids,  attention_masks,  labels