code: def create_dict_checkpoint(
      data: Dict[str, Any], checkpoint_cls: Type[Checkpoint] = None
  ) -> Checkpoint:
      with tempfile.TemporaryDirectory() as tmpdir:
          with open(os.path.join(tmpdir, "data.pkl"), "wb") as f:
              ray_pickle.dump(data, f)
          checkpoint_cls = checkpoint_cls or Checkpoint
          yield checkpoint_cls.from_directory(tmpdir)
  
file_path: ray/python/ray/train/tests/util.py
imports: import contextlib
  import os
  import tempfile
  from typing import Any, Dict, Optional, Type
  import ray.cloudpickle
  from ray.train import Checkpoint
  from ray.train._internal.storage import StorageContext
label_desc: Use image node_id 1 for calling a global function with example usage: create_dict_checkpoint(data, checkpoint_cls) without return types