code: def __init__(
      self,
      data_dir,
      tokenizer,
      train_file="lm_train.txt",
      val_file="lm_val.txt",
      batch_size_per_gpu=32,
      max_seq_length=512,
      multi_gpu=True,
      model_type="bert",
      logger=None,
      clear_cache=False,
      no_cache=False,
  ):
      # just in case someone passes string instead of Path
      if isinstance(data_dir, str):
          data_dir = Path(data_dir)
  
      # Instantiate correct tokenizer if the tokenizer name is passed instead of object
      if isinstance(tokenizer, str):
          _, _, tokenizer_class = MODEL_CLASSES[model_type]
          # instantiate the new tokeniser object using the tokeniser name
          tokenizer = tokenizer_class.from_pretrained(
              tokenizer, do_lower_case=("uncased" in tokenizer)
          )
  
      # Bug workaround for RoBERTa
      if model_type == "roberta":
          tokenizer.max_len_single_sentence = tokenizer.max_len - 2
  
      self.tokenizer = tokenizer
      self.max_seq_length = max_seq_length
      self.batch_size_per_gpu = batch_size_per_gpu
      self.train_dl = None
      self.val_dl = None
      self.data_dir = data_dir
      self.cache_dir = data_dir / "lm_cache"
      self.no_cache = no_cache
      self.model_type = model_type
      if logger is None:
          logger = logging.getLogger()
      self.logger = logger
      self.n_gpu = 1
      if multi_gpu:
          self.n_gpu = torch.cuda.device_count()
  
      if clear_cache:
          shutil.rmtree(self.cache_dir, ignore_errors=True)
  
      # Create folder if it doesn't exist
      self.cache_dir.mkdir(exist_ok=True)
  
      if train_file:
          # Train DataLoader
          # train_examples = None
          cached_features_file = os.path.join(
              self.cache_dir,
              "cached_{}_{}_{}".format(
                  self.model_type, "train", str(self.max_seq_length)
              ),
          )
  
          train_filepath = str(self.data_dir / train_file)
          train_dataset = TextDataset(
              self.tokenizer,
              train_filepath,
              cached_features_file,
              self.logger,
              block_size=self.tokenizer.max_len_single_sentence,
          )
  
          self.train_batch_size = self.batch_size_per_gpu * max(
              1, self.n_gpu
          )
  
          train_sampler = RandomSampler(train_dataset)
          self.train_dl = DataLoader(
              train_dataset,
              sampler=train_sampler,
              batch_size=self.train_batch_size,
          )
  
      if val_file:
          # Val DataLoader
          # val_examples = None
          cached_features_file = os.path.join(
              self.cache_dir,
              "cached_{}_{}_{}".format(
                  self.model_type, "dev", str(self.max_seq_length)
              ),
          )
  
          val_filepath = str(self.data_dir / val_file)
          val_dataset = TextDataset(
              self.tokenizer,
              val_filepath,
              cached_features_file,
              self.logger,
              block_size=self.tokenizer.max_len_single_sentence,
          )
  
          self.val_batch_size = (
              self.batch_size_per_gpu * 2 * max(1, self.n_gpu)
          )
  
          val_sampler = RandomSampler(val_dataset)
          self.val_dl = DataLoader(
              val_dataset,
              sampler=val_sampler,
              batch_size=self.val_batch_size,
          )
  
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 2 to create a new BertLMDataBunch object from inherited base classes: object with example: obj = BertLMDataBunch(data_dir, tokenizer, train_file, val_file, batch_size_per_gpu, max_seq_length, multi_gpu, model_type, logger, clear_cache, no_cache)