code: def _dump_snapshot(save_dir: str, snapshot: Dict[str, Any]) -> None:
      fs = get_filesystem(save_dir)
      fs.mkdirs(save_dir, exist_ok=True)
      with fs.open(
          os.path.join(save_dir, "snapshot.pickle"), "wb"
      ) as f:
          pickle.dump(snapshot, f)
      with fs.open(os.path.join(save_dir, "trace_plot.html"), "w") as f:
          f.write(torch.cuda._memory_viz.trace_plot(snapshot))
      with fs.open(
          os.path.join(save_dir, "segment_plot.html"), "w"
      ) as f:
          f.write(torch.cuda._memory_viz.segment_plot(snapshot))
  
file_path: tnt/torchtnt/utils/oom.py
imports: import logging
  import os
  import pickle
  from typing import Any, Callable, Dict, Optional, Union
  import torch
  from torchtnt.utils.distributed import get_global_rank
  from torchtnt.utils.fsspec import get_filesystem
  from torchtnt.utils.version import is_torch_version_geq_2_0
label_desc: Use image node_id 7 for calling a global function with example usage: _dump_snapshot(save_dir, snapshot) without return types