code: def pcd_3d_to_pcd_2d(
      pcd,
      intrinsic,
      extrinsic,
      size,
      keep_z,
      crop=True,
      filter_neg=True,
      norm_coord=True,
      return_index=False,
  ):
      assert isinstance(
          pcd, np.ndarray
      ), f"cannot process data type: {type(pcd)}"
      assert isinstance(
          intrinsic, np.ndarray
      ), f"cannot process data type: {type(intrinsic)}"
      assert isinstance(
          extrinsic, np.ndarray
      ), f"cannot process data type: {type(extrinsic)}"
      assert (
          len(pcd.shape) == 2 and pcd.shape[1] >= 3
      ), f"seems the input pcd is not a valid 3d point cloud: {pcd.shape}"
  
      xyzw = np.concatenate(
          [pcd[:, 0:3], np.ones_like(pcd[:, 0:1])], axis=1
      )
      mvp_mat = np.matmul(intrinsic, extrinsic)
      camera_points = np.matmul(mvp_mat, xyzw.T).T
      if filter_neg:
          valid_mask_1 = camera_points[:, 2] > 0.0
      else:
          valid_mask_1 = np.ones_like(camera_points[:, 2], dtype=bool)
      camera_points = camera_points[valid_mask_1]
      image_points = camera_points / camera_points[:, 2:3]
      image_points = image_points[:, :2]
      if crop:
          valid_mask_2 = (
              (image_points[:, 0] >= 0)
              * (image_points[:, 0] < size[1] - 1)
              * (image_points[:, 1] >= 0)
              * (image_points[:, 1] < size[0] - 1)
          )
      else:
          valid_mask_2 = np.ones_like(image_points[:, 0], dtype=bool)
      if norm_coord:
          image_points = ((image_points / size[::-1]) * 2) - 1
  
      if keep_z:
          image_points = np.concatenate(
              [
                  image_points[valid_mask_2],
                  camera_points[valid_mask_2][:, 2:3],
                  pcd[valid_mask_1][:, 3:][valid_mask_2],
              ],
              axis=1,
          )
      else:
          image_points = np.concatenate(
              [
                  image_points[valid_mask_2],
                  pcd[valid_mask_1][:, 3:][valid_mask_2],
              ],
              axis=1,
          )
      if return_index:
          points_index = np.arange(pcd.shape[0])[valid_mask_1][
              valid_mask_2
          ]
          return image_points, points_index
      return image_points
  
file_path: ml-neuman/geometry/pcd_projector.py
imports: import numpy
  import torch
label_desc: Use image node_id 4 for calling the PointCloudProjectorNp obj's underlying member method code with example usage: obj.pcd_3d_to_pcd_2d(pcd, intrinsic, extrinsic, size, keep_z, crop, filter_neg, norm_coord, return_index) and returns: image_points, image_points,  points_index