class_docstr: This will be superseded by a framework-agnostic approach
  soon.
code: def __init__(
      self,
      data_dir: str,
      file_name: str,
      tokenizer,
      labels: List[str],
      model_type: str,
      texts=None,
      max_seq_length: Optional[int] = None,
      overwrite_cache=False,
      mode: Split = Split.train,
      logger=logging.getLogger(__name__),
  ):
      # # Load data features from cache or dataset file
      # cached_features_file = os.path.join(
      #     data_dir,
      #     "cached_{}_{}_{}".format(
      #         mode.value, tokenizer.__class__.__name__, str(max_seq_length)
      #     ),
      # )
  
      # Make sure only the first process in distributed training processes the dataset,
      # and the others will use the cache.
      # lock_path = cached_features_file + ".lock"
      # with FileLock(lock_path):
  
      # if os.path.exists(cached_features_file) and not overwrite_cache:
      #     logger.info(f"Loading features from cached file {cached_features_file}")
      #     self.features = torch.load(cached_features_file)
      # else:
      logger.info(f"Creating features from dataset file at {data_dir}")
      examples = read_examples_from_file(data_dir, file_name, mode)
      self.features = convert_examples_to_features(
          examples,
          labels,
          max_seq_length,
          tokenizer,
          cls_token_at_end=bool(model_type in ["xlnet"]),
          # xlnet has a cls token at the end
          cls_token=tokenizer.cls_token,
          cls_token_segment_id=2 if model_type in ["xlnet"] else 0,
          sep_token=tokenizer.sep_token,
          sep_token_extra=False,
          # roberta uses an extra separator b/w pairs of sentences, cf. github.com/pytorch/fairseq/commit/1684e166e3da03f5b600dbb7855cb98ddfcd0805
          pad_on_left=bool(tokenizer.padding_side == "left"),
          pad_token=tokenizer.pad_token_id,
          pad_token_segment_id=tokenizer.pad_token_type_id,
          pad_token_label_id=self.pad_token_label_id,
          logger=logger,
      )
  
imports: import pandas
  import json
  import logging
  import os
  import torch
  from torch import nn
  from dataclasses import dataclass
  from enum import Enum
  from typing import List, Optional, Union
  from pathlib import Path
  import pickle
  from filelock import FileLock
  import re
  import shutil
  from sklearn.model_selection import train_test_split
  from torch.utils.data import Dataset, TensorDataset, DataLoader, RandomSampler, SequentialSampler
  from torch.utils.data.distributed import DistributedSampler
  from transformers import PreTrainedTokenizer, AutoTokenizer
label_desc: Use image node_id 1 to create a new NerDataset object from inherited base classes: Dataset with example: obj = NerDataset(data_dir, file_name, tokenizer, labels, model_type, texts, max_seq_length, overwrite_cache, mode, logger)