code: def project_image(proj, targets, png_prefix, num_snapshots):
      snapshot_steps = set(
          proj.num_steps
          - np.linspace(
              0,
              proj.num_steps,
              num_snapshots,
              endpoint=False,
              dtype=int,
          )
      )
      misc.save_image_grid(
          targets, png_prefix + "target.png", drange=[-1, 1]
      )
      proj.start(targets)
      while proj.get_cur_step() < proj.num_steps:
          print(
              "\r%d / %d ... " % (proj.get_cur_step(), proj.num_steps),
              end="",
              flush=True,
          )
          proj.step()
          if proj.get_cur_step() in snapshot_steps:
              misc.save_image_grid(
                  proj.get_images(),
                  png_prefix + "step%04d.png" % proj.get_cur_step(),
                  drange=[-1, 1],
              )
      print("\r%-30s\r" % "", end="", flush=True)
  
file_path: insightface/reconstruction/ostec/external/stylegan2/run_projector.py
imports: import argparse
  import numpy
  import dnnlib
  import dnnlib.tflib
  import re
  import sys
  import projector
  import pretrained_networks
  from training import dataset
  from training import misc
label_desc: Use image node_id 1 for calling a global function with example usage: project_image(proj, targets, png_prefix, num_snapshots) without return types