docstr: Tests whether implicit function finds the bounding box of the object and sends
  correct min and max points to voxel grids for rescaling.
docstr_tok: ["Tests","whether","implicit","function","finds","the","bounding","box","of","the","object","and","sends","correct","min","and","max","points","to","voxel","grids","for","rescaling","."]
code: def test_cropping(self, scaffold_res=9):
      """
      Tests whether implicit function finds the bounding box of the object and sends
      correct min and max points to voxel grids for rescaling.
      """
      device = "cuda" if torch.cuda.is_available() else "cpu"
      func = self._get_simple_implicit_function(
          scaffold_res=scaffold_res
      ).to(device)
  
      assert scaffold_res >= 8
      div = (scaffold_res - 1) / 2
      true_min_point = torch.tensor(
          [-3 / div, 0 / div, -3 / div],
          device=device,
      )
      true_max_point = torch.tensor(
          [1 / div, 2 / div, 3 / div],
          device=device,
      )
  
      def new_scaffold(points):
          # 1 if between true_min and true_max point else 0
          # return points.new_ones((*points.shape[:-1], 1))
          return (
              torch.logical_and(
                  true_min_point <= points, points <= true_max_point
              )
              .all(dim=-1)
              .float()[..., None]
          )
  
      called_crop = []
  
      def assert_min_max_points(min_point, max_point):
          called_crop.append(1)
          self.assertClose(min_point, true_min_point)
          self.assertClose(max_point, true_max_point)
  
      func.voxel_grid_density.crop_self = assert_min_max_points
      func.voxel_grid_color.crop_self = assert_min_max_points
      func.voxel_grid_scaffold.forward = new_scaffold
      func._scaffold_ready = True
      func._crop(epoch=0)
      assert len(called_crop) == 2
  
file_path: pytorch3d/tests/implicitron/test_voxel_grid_implicit_function.py
imports: import unittest
  import torch
  from omegaconf import DictConfig, OmegaConf
  from pytorch3d.implicitron.models.implicit_function.voxel_grid_implicit_function import VoxelGridImplicitFunction
  from pytorch3d.implicitron.models.renderer.base import ImplicitronRayBundle
  from pytorch3d.implicitron.tools.config import expand_args_fields, get_default_args
  from pytorch3d.renderer import ray_bundle_to_ray_points
  from tests.common_testing import TestCaseMixin
label_desc: Use image node_id 6 for calling the TestVoxelGridImplicitFunction obj's underlying member method code with example usage: obj.test_cropping(scaffold_res) and returns: torch