code: def get_dataset_from_examples(
      self, examples, set_type="train", is_test=False, no_cache=False
  ):
      if set_type == "train":
          file_name = self.train_file
      elif set_type == "dev":
          file_name = self.val_file
      elif set_type == "test":
          file_name = "test"  # test is not supposed to be a file - just a list of texts
  
      cached_features_file = os.path.join(
          self.cache_dir,
          "cached_{}_{}_{}_{}_{}".format(
              self.model_type.replace("/", "-"),
              set_type,
              "multi_label" if self.multi_label else "multi_class",
              str(self.max_seq_length),
              os.path.basename(file_name),
          ),
      )
  
      if os.path.exists(cached_features_file) and no_cache is False:
          self.logger.info(
              "Loading features from cached file %s",
              cached_features_file,
          )
          features = torch.load(cached_features_file)
      else:
          # Create tokenized and numericalized features
          features = convert_examples_to_features(
              examples,
              label_list=self.labels,
              max_seq_length=self.max_seq_length,
              tokenizer=self.tokenizer,
              output_mode=self.output_mode,
              # xlnet has a cls token at the end
              cls_token_at_end=bool(self.model_type in ["xlnet"]),
              cls_token=self.tokenizer.cls_token,
              sep_token=self.tokenizer.sep_token,
              cls_token_segment_id=2
              if self.model_type in ["xlnet"]
              else 0,
              # pad on the left for xlnet
              pad_on_left=bool(self.model_type in ["xlnet"]),
              pad_token_segment_id=4
              if self.model_type in ["xlnet"]
              else 0,
              logger=self.logger,
          )
  
          # Create folder if it doesn't exist
          if no_cache is False:
              self.cache_dir.mkdir(exist_ok=True)
              self.logger.info(
                  "Saving features into cached file %s",
                  cached_features_file,
              )
              torch.save(features, cached_features_file)
  
      # Convert to Tensors and build dataset
      all_input_ids = torch.tensor(
          [f.input_ids for f in features], dtype=torch.long
      )
      all_input_mask = torch.tensor(
          [f.input_mask for f in features], dtype=torch.long
      )
      all_segment_ids = torch.tensor(
          [f.segment_ids for f in features], dtype=torch.long
      )
  
      if is_test is False:  # labels not available for test set
          if self.multi_label:
              all_label_ids = torch.tensor(
                  [f.label_id for f in features], dtype=torch.float
              )
          else:
              all_label_ids = torch.tensor(
                  [f.label_id for f in features], dtype=torch.long
              )
  
          dataset = TensorDataset(
              all_input_ids,
              all_input_mask,
              all_segment_ids,
              all_label_ids,
          )
      else:
          all_label_ids = []
          dataset = TensorDataset(
              all_input_ids, all_input_mask, all_segment_ids
          )
  
      return dataset
  
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 4 for calling the BertDataBunch obj's underlying member method code with example usage: obj.get_dataset_from_examples(examples, set_type, is_test, no_cache) and returns: dataset