code: def parse_resume_step_from_filename(
      filename: Union[str, Path]
  ) -> int:
      """
      Parse filenames of the form path/to/modelNNNNNN.pt or
      path/to/ema_0.xxxx_NNNNNN.pt, where NNNNNN is the
      checkpoint's number of steps.
  
      Adapted from `improved-diffusion.train_util.parse_resume_step_from_filename`
      (https://github.com/openai/improved-diffusion)
      to parse checkpoints of exponential moving averages and codecs.
  
      Args:
          filename: Path of the model/ema checkpoint.
      Returns:
          The resume step of the checkpoint.
      """
      path = Path(filename)
      assert path.suffix in [".pt", ".npz"]
      assert any(
          s in path.name for s in ["ema", "model", "encode", "decode"]
      )
      return int(path.stem[-6:])
  
imports: import copy
  import hashlib
  from pathlib import Path
  from typing import List, Set, Union
  import numpy
  import plotly.graph_objs
  import torch
  import torch.distributed
  import wandb
  from hydra.core.hydra_config import HydraConfig
  from hydra.utils import instantiate, to_absolute_path
  from improved_diffusion import dist_util
  from improved_diffusion import gaussian_diffusion
  from improved_diffusion import logger, respace, train_util
  from omegaconf import DictConfig, OmegaConf
label_desc: Use image node_id 2 for calling a global function with example usage: parse_resume_step_from_filename(filename) and returns: int