code: def hf_dataset(
      name,
      image_transforms=[],
      image_column="img",
      label_column="label",
      text_column="txt",
      split="train",
      image_key="image",
      caption_key="txt",
  ):
      """Make huggingface dataset with appropriate list of transforms applied"""
      ds = load_dataset(name, split=split)
      image_transforms = [
          instantiate_from_config(tt) for tt in image_transforms
      ]
      image_transforms.extend(
          [
              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 (
          label_column in ds.column_names
      ), f"Didn't find column {label_column} in {ds.column_names}"
  
      def pre_process(examples):
          processed = {}
          processed[image_key] = [
              tform(im) for im in examples[image_column]
          ]
  
          label_to_text_dict = {
              0: "airplane",
              1: "automobile",
              2: "bird",
              3: "cat",
              4: "deer",
              5: "dog",
              6: "frog",
              7: "horse",
              8: "ship",
              9: "truck",
          }
  
          processed[caption_key] = [
              label_to_text_dict[label]
              for label in examples[label_column]
          ]
  
          return processed
  
      ds.set_transform(pre_process)
      return ds
  
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(name, image_transforms, image_column, label_column, text_column, split, image_key, caption_key) and returns: ds, processed