code: def hf_dataset(
      path="Fazzie/Teyvat",
      image_transforms=[],
      image_column="image",
      text_column="text",
      image_key="image",
      caption_key="txt",
  ):
      """Make huggingface dataset with appropriate list of transforms applied"""
      ds = load_dataset(path, name="train")
      ds = ds["train"]
      image_transforms = [
          instantiate_from_config(tt) for tt in image_transforms
      ]
      image_transforms.extend(
          [
              transforms.Resize((256, 256)),
              transforms.ToTensor(),
              transforms.Lambda(
                  lambda x: rearrange(x * 2.0 - 1.0, "c h w -> h w c")
              ),
          ]
      )
      tform = transforms.Compose(image_transforms)
  
      assert (
          image_column in ds.column_names
      ), f"Didn't find column {image_column} in {ds.column_names}"
      assert (
          text_column in ds.column_names
      ), f"Didn't find column {text_column} in {ds.column_names}"
  
      def pre_process(examples):
          processed = {}
          processed[image_key] = [
              tform(im) for im in examples[image_column]
          ]
          processed[caption_key] = examples[text_column]
  
          return processed
  
      ds.set_transform(pre_process)
      return ds
  
file_path: colossalai/examples/images/diffusion/ldm/data/teyvat.py
imports: import json
  from pathlib import Path
  from typing import Dict
  import torch
  from datasets import load_dataset
  from einops import rearrange
  from ldm.util import instantiate_from_config
  from omegaconf import DictConfig, ListConfig
  from PIL import Image
  from torch.utils.data import Dataset
  from torchvision import transforms
label_desc: Use image node_id 2 for calling a global function with example usage: hf_dataset(path, image_transforms, image_column, text_column, image_key, caption_key) and returns: ds, processed