code: def convert_examples_to_features(
      examples,
      label_list,
      max_seq_length,
      tokenizer,
      output_mode="classification",
      cls_token_at_end=False,
      pad_on_left=False,
      cls_token="[CLS]",
      sep_token="[SEP]",
      pad_token=0,
      sequence_a_segment_id=0,
      sequence_b_segment_id=1,
      cls_token_segment_id=1,
      pad_token_segment_id=0,
      mask_padding_with_zero=True,
      logger=None,
  ):
      """Loads a data file into a list of `InputBatch`s
      `cls_token_at_end` define the location of the CLS token:
          - False (Default, BERT/XLM pattern): [CLS] + A + [SEP] + B + [SEP]
          - True (XLNet/GPT pattern): A + [SEP] + B + [SEP] + [CLS]
      `cls_token_segment_id` define the segment id associated to the CLS token (0 for BERT, 2 for XLNet)
      """
  
      label_map = {label: i for i, label in enumerate(label_list)}
  
      features = []
      for ex_index, example in enumerate(examples):
          if ex_index % 10000 == 0:
              if logger:
                  logger.info(
                      "Writing example %d of %d"
                      % (ex_index, len(examples))
                  )
  
          tokens_a = tokenizer.tokenize(str(example.text_a))
  
          tokens_b = None
          if example.text_b:
              tokens_b = tokenizer.tokenize(str(example.text_b))
              # Modifies `tokens_a` and `tokens_b` in place so that the total
              # length is less than the specified length.
              # Account for [CLS], [SEP], [SEP] with "- 3"
              _truncate_seq_pair(tokens_a, tokens_b, max_seq_length - 3)
          else:
              # Account for [CLS] and [SEP] with "- 2"
              if len(tokens_a) > max_seq_length - 2:
                  tokens_a = tokens_a[: (max_seq_length - 2)]
  
          # The convention in BERT is:
          # (a) For sequence pairs:
          #  tokens:   [CLS] is this jack ##son ##ville ? [SEP] no it is not . [SEP]
          #  type_ids:   0   0  0    0    0     0       0   0   1  1  1  1   1   1
          # (b) For single sequences:
          #  tokens:   [CLS] the dog is hairy . [SEP]
          #  type_ids:   0   0   0   0  0     0   0
          #
          # Where "type_ids" are used to indicate whether this is the first
          # sequence or the second sequence. The embedding vectors for `type=0` and
          # `type=1` were learned during pre-training and are added to the wordpiece
          # embedding vector (and position vector). This is not *strictly* necessary
          # since the [SEP] token unambiguously separates the sequences, but it makes
          # it easier for the model to learn the concept of sequences.
          #
          # For classification tasks, the first vector (corresponding to [CLS]) is
          # used as as the "sentence vector". Note that this only makes sense because
          # the entire model is fine-tuned.
          tokens = tokens_a + [sep_token]
          segment_ids = [sequence_a_segment_id] * len(tokens)
  
          if tokens_b:
              tokens += tokens_b + [sep_token]
              segment_ids += [sequence_b_segment_id] * (
                  len(tokens_b) + 1
              )
  
          if cls_token_at_end:
              tokens = tokens + [cls_token]
              segment_ids = segment_ids + [cls_token_segment_id]
          else:
              tokens = [cls_token] + tokens
              segment_ids = [cls_token_segment_id] + segment_ids
  
          input_ids = tokenizer.convert_tokens_to_ids(tokens)
  
          # The mask has 1 for real tokens and 0 for padding tokens. Only real
          # tokens are attended to.
          input_mask = [1 if mask_padding_with_zero else 0] * len(
              input_ids
          )
  
          # Zero-pad up to the sequence length.
          padding_length = max_seq_length - len(input_ids)
          if pad_on_left:
              input_ids = ([pad_token] * padding_length) + input_ids
              input_mask = (
                  [0 if mask_padding_with_zero else 1] * padding_length
              ) + input_mask
              segment_ids = (
                  [pad_token_segment_id] * padding_length
              ) + segment_ids
          else:
              input_ids = input_ids + ([pad_token] * padding_length)
              input_mask = input_mask + (
                  [0 if mask_padding_with_zero else 1] * padding_length
              )
              segment_ids = segment_ids + (
                  [pad_token_segment_id] * padding_length
              )
  
          assert len(input_ids) == max_seq_length
          assert len(input_mask) == max_seq_length
          assert len(segment_ids) == max_seq_length
  
          if isinstance(example.label, list):
              label_id = []
              for label in example.label:
                  label_id.append(float(label))
          else:
              if example.label is not None:
                  label_id = label_map[example.label]
              else:
                  label_id = ""
  
          features.append(
              InputFeatures(
                  input_ids=input_ids,
                  input_mask=input_mask,
                  segment_ids=segment_ids,
                  label_id=label_id,
              )
          )
      return features
  
imports: import pandas
  import os
  import torch
  from pathlib import Path
  import pickle
  import logging
  import shutil
  from torch.utils.data import Dataset, TensorDataset, DataLoader, RandomSampler, SequentialSampler
  from torch.utils.data.distributed import DistributedSampler
  from transformers import AutoTokenizer
label_desc: Use image node_id 2 for calling a global function with example usage: convert_examples_to_features(examples, label_list, max_seq_length, tokenizer, output_mode, cls_token_at_end, pad_on_left, cls_token, sep_token, pad_token, sequence_a_segment_id, sequence_b_segment_id, cls_token_segment_id, pad_token_segment_id, mask_padding_with_zero, logger) and returns: features