def prune_dense_mask(self, threshold=0.02):
        """
        Just gradually prune the mask of dense volume to decrease the number of sdf network inference
        :return:
        """
        chunk_size = 10240
        coords = generate_grid(self.vol_dims_lod0, 1)[0]  # [3, dX, dY, dZ]

        _, dX, dY, dZ = coords.shape

        pts = coords.view(3, -1).permute(1,
                                         0).contiguous() * self.voxel_size_lod0 + self.origin[None, :]  # [dX*dY*dZ, 3]

        # dense_volume = self.dense_volume_lod0()  # [1,C,dX,dY,dZ]
        dense_volume, _ = sparse_to_dense_volume(
            self.sparse_coords_lod0,
            self.sparse_volume_lod0(), self.vol_dims_lod0, interval=1,
            device=None)  # [1, C/1, X, Y, Z]

        sdf_volume = torch.ones([dX * dY * dZ, 1]).float().to(dense_volume.device) * 100

        mask = self.dense_volume_mask_lod0.view(-1) > 0

        pts_valid = pts[mask].to(dense_volume.device)
        feature_valid = dense_volume.view(self.regnet_d_out, -1).permute(1, 0).contiguous()[mask]

        pts_valid = pts_valid.split(chunk_size)
        feature_valid = feature_valid.split(chunk_size)

        sdf_list = []

        for pts_part, feature_part in zip(pts_valid, feature_valid):
            sdf_part = self.sdf_layer(pts_part, feature_part)[:, :1]
            sdf_list.append(sdf_part)

        sdf_list = torch.cat(sdf_list, dim=0)

        sdf_volume[mask] = sdf_list

        occupancy_mask = torch.abs(sdf_volume) < threshold  # [num_pts, 1]

        # - dilate
        occupancy_mask = occupancy_mask.float()
        occupancy_mask = occupancy_mask.view(1, 1, dX, dY, dZ)
        occupancy_mask = F.avg_pool3d(occupancy_mask, kernel_size=7, stride=1, padding=3)
        occupancy_mask = occupancy_mask > 0

        self.dense_volume_mask_lod0 = torch.logical_and(self.dense_volume_mask_lod0,
                                                        occupancy_mask).float()  # (1, 1, dX, dY, dZ)

        Just gradually prune the mask of dense volume to decrease the number of sdf network inference
        :return:
        
mv-diffusion/One-2-3-45-by-view/reconstruction/models/sparse_sdf_network.py