code: def load_model(
      path: Path, device: torch.device
  ) -> SpectrogramGenerator:
      model = None
      if path.suffix == ".nemo":
          model = SpectrogramGenerator.restore_from(
              path, map_location=device
          )
      elif path.suffix == ".ckpt":
          model = SpectrogramGenerator.load_from_checkpoint(
              path, map_location=device
          )
      else:
          raise ValueError(
              f"Unknown checkpoint type {path.suffix} ({path})"
          )
  
      return model.eval().to(device)
  
imports: import argparse
  import itertools
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Any, Dict, Iterable, Iterator, List
  import numpy
  import torch
  from omegaconf import DictConfig, OmegaConf
  from tqdm import tqdm
  from nemo.collections.asr.parts.utils.manifest_utils import read_manifest, write_manifest
  from nemo.collections.tts.models import FastPitchModel
  from nemo.collections.tts.models.base import SpectrogramGenerator
  from nemo.collections.tts.parts.utils.helpers import process_batch, to_device_recursive
label_desc: Use image node_id 2 for calling a global function with example usage: load_model(path, device) and returns: model