code: def __init__(
      self, tokenizer, file_path, cache_path, logger, block_size=512
  ):
      assert os.path.isfile(file_path)
  
      if os.path.exists(cache_path):
          logger.info(
              "Loading features from cached file %s", cache_path
          )
          with open(cache_path, "rb") as handle:
              self.examples = pickle.load(handle)
      else:
          logger.info(
              "Creating features from dataset file %s", file_path
          )
  
          self.examples = []
          text = (
              line.strip() for line in open(file_path, encoding="utf-8")
          )
          text = progress_bar(list(text))
          text = map(
              lambda x: tokenizer.convert_tokens_to_ids(
                  tokenizer.tokenize(x)
              ),
              text,
          )
          text = itertools.chain.from_iterable(text)
          text = more_itertools.chunked(text, block_size)
          self.examples = list(text)[:-1]
          # Note that we are loosing the last truncated example here for the sake of simplicity (no padding)
          # If your dataset is small, first you should loook for a bigger one :-) and second you
          # can change this behavior by adding (model specific) padding.
  
          logger.info("Saving features into cached file %s", cache_path)
          with open(cache_path, "wb") as handle:
              pickle.dump(
                  self.examples,
                  handle,
                  protocol=pickle.HIGHEST_PROTOCOL,
              )
  
imports: import re
  import html
  import logging
  import pandas
  import os
  import random
  import torch
  from pathlib import Path
  import pickle
  import shutil
  import itertools
  import more_itertools
  from sklearn.model_selection import train_test_split
  from torch.utils.data import TensorDataset, DataLoader, RandomSampler, SequentialSampler, Dataset
  from torch.utils.data.distributed import DistributedSampler
  import spacy
  from tqdm import tqdm, trange
  from fastprogress.fastprogress import master_bar, progress_bar
  from transformers import WEIGHTS_NAME, BertConfig, BertForSequenceClassification, BertTokenizer, XLMConfig, XLMForSequenceClassification, XLMTokenizer, XLNetConfig, XLNetForSequenceClassification, XLNetTokenizer, RobertaConfig, RobertaForSequenceClassification, RobertaTokenizer, DistilBertConfig, DistilBertForSequenceClassification, DistilBertTokenizer, CamembertConfig, CamembertForSequenceClassification, CamembertTokenizer, ElectraConfig, ElectraForSequenceClassification, ElectraTokenizer
label_desc: Use image node_id 1 to create a new TextDataset object from inherited base classes: Dataset with example: obj = TextDataset(tokenizer, file_path, cache_path, logger, block_size)