class_docstr: A `DataLoader` suitable for language modeling
class_docstr_tok: ["A","`","DataLoader","`","suitable","for","language","modeling"]
code: def __init__(
      self,
      dataset,
      lens=None,
      cache=2,
      bs=64,
      seq_len=72,
      num_workers=0,
      **kwargs,
  ):
      self.items = ReindexCollection(
          dataset, cache=cache, tfm=_maybe_first
      )
      self.seq_len = seq_len
      if lens is None:
          lens = _get_lengths(dataset)
      if lens is None:
          lens = [len(o) for o in self.items]
      self.lens = ReindexCollection(lens, idxs=self.items.idxs)
      # The "-1" is to allow for final label, we throw away the end that's less than bs
      corpus = round_multiple(sum(lens) - 1, bs, round_down=True)
      self.bl = corpus // bs  # bl stands for batch length
      self.n_batches = self.bl // (seq_len) + int(
          self.bl % seq_len != 0
      )
      self.last_len = self.bl - (self.n_batches - 1) * seq_len
      self.make_chunks()
      super().__init__(
          dataset=dataset, bs=bs, num_workers=num_workers, **kwargs
      )
      self.n = self.n_batches * bs
  
imports: from __future__ import annotations
  from ..torch_basics import *
  from ..data.all import *
  from .core import *
label_desc: Use image node_id 1 to create a new LMDataLoader object from inherited base classes: TfmdDL with example: obj = LMDataLoader(dataset, lens, cache, bs, seq_len, num_workers)