code: def __init__(self, data_cfg: DataConfig) -> None:
      print(data_cfg.path)
      data = fsspec.open(data_cfg.path).open().read().decode("utf-8")
      data = data[: int(len(data) * data_cfg.truncate)]
  
      chars = sorted(set(data))
      data_size, vocab_size = len(data), len(chars)
      print(
          "Data has %d characters, %d unique." % (data_size, vocab_size)
      )
  
      self.stoi: Dict[str, int] = {ch: i for i, ch in enumerate(chars)}
      self.itos: Dict[int, str] = {i: ch for i, ch in enumerate(chars)}
      self.block_size: int = data_cfg.block_size
      self.vocab_size: int = vocab_size
      self.data: str = data
  
file_path: tnt/examples/mingpt/char_dataset.py
imports: from dataclasses import dataclass
  from typing import Dict, Tuple
  import fsspec
  import torch
  from torch.utils.data import Dataset
label_desc: Use image node_id 1 to create a new CharDataset object from inherited base classes: Dataset with example: obj = CharDataset(data_cfg)