docstr: Test rendering meshes formed from voxels.
docstr_tok: ["Test","rendering","meshes","formed","from","voxels","."]
code: def test_render_voxels(self):
      """
      Test rendering meshes formed from voxels.
      """
      # Set up device and seed for random selections.
      device = torch.device("cuda:0")
  
      # Load dataset in the train split with only a single view returned for each model.
      r2n2_dataset = R2N2(
          "train",
          SHAPENET_PATH,
          R2N2_PATH,
          SPLITS_PATH,
          return_voxels=True,
          voxels_rel_path=VOXELS_REL_PATH,
      )
      r2n2_model = r2n2_dataset[6, [5]]
      vox_render = render_cubified_voxels(
          r2n2_model["voxels"], device=device
      )
      vox_render_rgb = vox_render[0, ..., :3].squeeze().cpu()
      if DEBUG:
          Image.fromarray(
              (vox_render_rgb.numpy() * 255).astype(np.uint8)
          ).save(DATA_DIR / ("DEBUG_r2n2_voxel_to_mesh_render.png"))
      image_ref = load_rgb_image(
          "test_r2n2_voxel_to_mesh_render.png", DATA_DIR
      )
      self.assertClose(vox_render_rgb, image_ref, atol=0.05)
  
imports: import json
  import os
  import unittest
  import numpy
  import torch
  from PIL import Image
  from pytorch3d.datasets import BlenderCamera, collate_batched_R2N2, R2N2, render_cubified_voxels
  from pytorch3d.renderer import FoVPerspectiveCameras, look_at_view_transform, PointLights, RasterizationSettings
  from pytorch3d.renderer.cameras import get_world_to_view_transform
  from pytorch3d.transforms import Transform3d
  from pytorch3d.transforms.so3 import so3_exp_map
  from torch.utils.data import DataLoader
  from .common_testing import get_tests_dir, load_rgb_image, TestCaseMixin
label_desc: Use image node_id 8 for calling the TestR2N2 obj's underlying member method code with example usage: obj.test_render_voxels() without return types