code: def to_tokens(self, message, device):
      return torch.tensor(
          [self.stoi[s] for s in message], dtype=torch.long
      )[None, ...].to(device)
  
imports: import math
  import os
  import pytorch_lightning
  import torch
  import torch.nn
  from pytorch_lightning import Trainer, seed_everything
  from pytorch_lightning.utilities import rank_zero_info
  from torch.nn import functional
  from torch.utils.data import DataLoader, Dataset, RandomSampler
  from xformers.factory.model_factory import xFormer, xFormerConfig
label_desc: Use image node_id 4 for calling the CharDataset obj's underlying member method code with example usage: obj.to_tokens(message, device) and returns: torch