code: def cli():
      """
      Camera optimization example using pulsar.
  
      Writes to `cam.gif`.
      """
      LOGGER.info("Loading reference...")
      # Load reference.
      ref = (
          torch.from_numpy(
              imageio.imread(
                  "../../tests/pulsar/reference/examples_TestRenderer_test_cam.png"
              )[:, ::-1, :].copy()
          ).to(torch.float32)
          / 255.0
      ).to(DEVICE)
      # Set up model.
      model = SceneModel().to(DEVICE)
      # Optimizer.
      optimizer = optim.SGD(
          [
              {"params": [model.cam_pos], "lr": 1e-4},
              {"params": [model.cam_rot], "lr": 5e-6},
              # Using a higher lr for the focal length here, because
              # the sensor width can not be optimized directly.
              {"params": [model.focal_length], "lr": 1e-3},
          ]
      )
  
      LOGGER.info(
          "Writing video to `%s`.", path.abspath("cam-pt3d.gif")
      )
      writer = imageio.get_writer("cam-pt3d.gif", format="gif", fps=25)
  
      # Optimize.
      for i in range(300):
          optimizer.zero_grad()
          result = model()
          # Visualize.
          result_im = (result.cpu().detach().numpy() * 255).astype(
              np.uint8
          )
          cv2.imshow("opt", result_im[:, :, ::-1])
          writer.append_data(result_im)
          overlay_img = np.ascontiguousarray(
              (
                  (result * 0.5 + ref * 0.5).cpu().detach().numpy()
                  * 255
              ).astype(np.uint8)[:, :, ::-1]
          )
          overlay_img = cv2.putText(
              overlay_img,
              "Step %d" % (i),
              (10, 40),
              cv2.FONT_HERSHEY_SIMPLEX,
              1,
              (0, 0, 0),
              2,
              cv2.LINE_AA,
              False,
          )
          cv2.imshow("overlay", overlay_img)
          cv2.waitKey(1)
          # Update.
          loss = ((result - ref) ** 2).sum()
          LOGGER.info("loss %d: %f", i, loss.item())
          loss.backward()
          optimizer.step()
      writer.close()
      LOGGER.info("Done.")
  
file_path: pytorch3d/docs/examples/pulsar_cam_unified.py
imports: import logging
  from os import path
  import cv2
  import imageio
  import numpy
  import torch
  from pytorch3d.renderer.cameras import PerspectiveCameras
  from pytorch3d.renderer.points import PointsRasterizationSettings, PointsRasterizer, PulsarPointsRenderer
  from pytorch3d.structures.pointclouds import Pointclouds
  from pytorch3d.transforms import axis_angle_to_matrix
  from torch import nn, optim
label_desc: Use image node_id 1 for calling a global function with example usage: cli() without return types