code: def test_camera(self):
      data = _CommonData()
      # Our point, plus the image center, and a corner of the image.
      # Located at the focal-length distance away
      points = torch.tensor(
          [data.point, [0, 0, 1], [1, data.H / data.W, 1]]
      )
      for cameras in (data.camera_ndc, data.camera_screen):
          ndc_points = cameras.transform_points_ndc(points)
          screen_points = cameras.transform_points_screen(points)
          screen_points_without_xyflip = (
              cameras.transform_points_screen(points, with_xyflip=False)
          )
          camera_points = cameras.transform_points(points)
          for batch_idx in range(2):
              # NDC space agrees with the original
              self.assertClose(ndc_points[batch_idx], points, atol=1e-5)
              # First point in screen space is the center of our expected pixel
              self.assertClose(
                  screen_points[batch_idx][0],
                  torch.tensor([data.x + 0.5, data.y + 0.5, 1.0]),
                  atol=1e-5,
              )
              # Screen coords without xyflip should have x, y that negate the non-
              # flipped values, and unchanged z.
              self.assertClose(
                  screen_points_without_xyflip[batch_idx][0],
                  torch.tensor([-(data.x + 0.5), -(data.y + 0.5), 1.0]),
                  atol=1e-5,
              )
              # Second point in screen space is the center of the screen
              self.assertClose(
                  screen_points[batch_idx][1],
                  torch.tensor([data.W / 2.0, data.H / 2.0, 1.0]),
                  atol=1e-5,
              )
              # Third point in screen space is the corner of the screen
              # (corner of corner pixels)
              self.assertClose(
                  screen_points[batch_idx][2],
                  torch.tensor([0.0, 0.0, 1.0]),
                  atol=1e-5,
              )
  
              if cameras.in_ndc():
                  self.assertClose(
                      camera_points[batch_idx], ndc_points[batch_idx]
                  )
              else:
                  # transform_points does something strange for screen cameras
                  if batch_idx == 0:
                      wanted = torch.stack(
                          [
                              data.W - screen_points[batch_idx, :, 0],
                              data.H - screen_points[batch_idx, :, 1],
                              torch.ones(3),
                          ],
                          dim=1,
                      )
                  else:
                      wanted = torch.stack(
                          [
                              -screen_points[batch_idx, :, 0],
                              2 * data.H
                              - screen_points[batch_idx, :, 1],
                              torch.ones(3),
                          ],
                          dim=1,
                      )
                  self.assertClose(camera_points[batch_idx], wanted)
  
file_path: pytorch3d/tests/test_camera_pixels.py
imports: import unittest
  import torch
  from pytorch3d.renderer import MeshRasterizer, NDCMultinomialRaysampler, PerspectiveCameras, PointsRasterizationSettings, PointsRasterizer, PulsarPointsRenderer, RasterizationSettings
  from pytorch3d.structures import Meshes, Pointclouds
  from .common_testing import TestCaseMixin
label_desc: Use image node_id 4 for calling the TestPixels obj's underlying member method code with example usage: obj.test_camera() without return types