def simulate_lidar_from_depth(depth_img, camera_intrinsics, camera_translation, camera_rotation):
        """
        Simulate LiDAR points in the world coordinate system from a depth image.

        Parameters:
            depth_img (np.ndarray): Depth image of shape (H, W, 3), where the last dimension represents RGB or grayscale depth values.
            camera_intrinsics (np.ndarray): Camera intrinsic matrix of shape (3, 3).
            camera_translation (np.ndarray): Translation vector of the camera in world coordinates of shape (3,).
            camera_rotation (np.ndarray): Rotation matrix of the camera in world coordinates of shape (3, 3).

        Returns:
            np.ndarray: LiDAR points in the world coordinate system of shape (N, 3), where N is the number of valid points.
        """
        # Extract the depth channel (assuming it's grayscale or depth is in the R channel)
        # Get image dimensions
        depth_img = depth_img.T
        depth_img = depth_img[::-1, ::-1]
        height, width = depth_img.shape

        # Create a grid of pixel coordinates (u, v)
        u, v = np.meshgrid(np.arange(width), np.arange(height))
        uv_coords = np.stack([u, v, np.ones_like(u)], axis=-1)  # Shape: (H, W, 3)

        # Reshape to (H*W, 3) for easier matrix multiplication
        uv_coords = uv_coords.reshape(-1, 3)

        # Invert the camera intrinsic matrix to project pixels to camera coordinates
        K_inv = np.linalg.inv(camera_intrinsics)

        # Compute 3D points in the camera coordinate system
        cam_coords = (K_inv @ uv_coords.T).T  # Shape: (H*W, 3)
        cam_coords *= depth_img.reshape(-1)[..., None]  # Scale by depth

        # Remove invalid points (e.g., depth = 0)
        # valid_mask = depth_img.flatten() > 0
        # cam_coords = cam_coords[valid_mask]
        cam_coords = cam_coords[..., [2, 1, 0]]

        # Transform points to the world coordinate system
        world_coords = (camera_rotation @ cam_coords.T).T + camera_translation

        # to original shape
        world_coords = world_coords.reshape(height, width, 3)
        return world_coords.swapaxes(0, 1)

        Simulate LiDAR points in the world coordinate system from a depth image.

        Parameters:
            depth_img (np.ndarray): Depth image of shape (H, W, 3), where the last dimension represents RGB or grayscale depth values.
            camera_intrinsics (np.ndarray): Camera intrinsic matrix of shape (3, 3).
            camera_translation (np.ndarray): Translation vector of the camera in world coordinates of shape (3,).
            camera_rotation (np.ndarray): Rotation matrix of the camera in world coordinates of shape (3, 3).

        Returns:
            np.ndarray: LiDAR points in the world coordinate system of shape (N, 3), where N is the number of valid points.
        
metadrive/component/sensors/point_cloud_lidar.py