code: def test_raysampler(self):
      data = _CommonData()
      gridsampler = NDCMultinomialRaysampler(
          image_width=data.W,
          image_height=data.H,
          n_pts_per_ray=2,
          min_depth=1.0,
          max_depth=2.0,
      )
      for camera in (data.camera_ndc, data.camera_screen):
          bundle = gridsampler(camera)
          self.assertTupleEqual(
              bundle.xys.shape, (2,) + data.image_size + (2,)
          )
          self.assertTupleEqual(
              bundle.directions.shape, (2,) + data.image_size + (3,)
          )
          self.assertClose(
              bundle.xys[:, data.y, data.x],
              torch.tensor(data.point[:2]).expand(2, -1),
          )
          # We check only the first batch element.
          # Second element varies because of camera location.
          self.assertClose(
              bundle.directions[0, data.y, data.x],
              torch.tensor(data.point),
          )
  
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 3 for calling the TestPixels obj's underlying member method code with example usage: obj.test_raysampler() without return types