class_docstr: Base class for all the voxel grid variants whith added trilinear interpolation between
  voxels (for example if voxel (0.333, 1, 3) is queried that would return the result
  2/3*voxel[0, 1, 3] + 1/3*voxel[1, 1, 3])
  
  Internally voxel grids are indexed by (features, x, y, z). If queried the point is not
  inside the voxel grid the vector that will be returned is determined by padding.
  
  Members:
      align_corners: parameter used in torch.functional.grid_sample. For details go to
          https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html by
          default is True
      padding: padding mode for outside grid values 'zeros' | 'border' | 'reflection'.
          Default is 'zeros'
      mode: interpolation mode to calculate output values :
          'bilinear' | 'nearest' | 'bicubic' | 'trilinear'.
          Default: 'bilinear' Note: mode='bicubic' supports only FullResolutionVoxelGrid.
          When mode='bilinear' and the input is 5-D, the interpolation mode used internally
          will actually be trilinear.
      n_features: number of dimensions of base feature vector. Determines how many features
          the grid returns.
      resolution_changes: a dictionary, where keys are change epochs and values are
          3-tuples containing x, y, z grid sizes corresponding to each axis to each epoch
class_docstr_tok: ["Base","class","for","all","the","voxel","grid","variants","whith","added","trilinear","interpolation","between","voxels","(","for","example","if","voxel","(","0.333",",","1",",","3",")","is","queried","that","would","return","the","result","2\/3","*","voxel","[","0",",","1",",","3","]","+","1\/3","*","voxel","[","1",",","1",",","3","]",")","Internally","voxel","grids","are","indexed","by","(","features",",","x",",","y",",","z",")",".","If","queried","the","point","is","not","inside","the","voxel","grid","the","vector","that","will","be","returned","is","determined","by","padding",".","Members",":","align_corners",":","parameter","used","in","torch.functional.grid_sample",".","For","details","go","to","https",":","\/\/pytorch.org\/docs\/stable\/generated\/torch.nn.functional.grid_sample.html","by","default","is","True","padding",":","padding","mode","for","outside","grid","values","'zeros","'","|","'border","'","|","'reflection","'",".","Default","is","'zeros'","mode",":","interpolation","mode","to","calculate","output","values",":","'bilinear","'","|","'nearest","'","|","'bicubic","'","|","'trilinear","'",".","Default",":","'bilinear","'","Note",":","mode='bicubic","'","supports","only","FullResolutionVoxelGrid",".","When","mode='bilinear","'","and","the","input","is","5-D",",","the","interpolation","mode","used","internally","will","actually","be","trilinear",".","n_features",":","number","of","dimensions","of","base","feature","vector",".","Determines","how","many","features","the","grid","returns",".","resolution_changes",":","a","dictionary",",","where","keys","are","change","epochs","and","values","are","3-tuples","containing","x",",","y",",","z","grid","sizes","corresponding","to","each","axis","to","each","epoch"]
docstr: Changes resolution of tensors in `grid_values` to match the
  `grid_values_with_wanted_resolution` or resolution on wanted epoch.
  
  Args:
      epoch: current training epoch, used to see if the grid needs regridding
      grid_values: instance of self.values_type which contains
          the voxel grid which will be interpolated to create the new grid
      epoch: epoch which is used to get the resolution of the new
          `grid_values` using `self.resolution_changes`.
      grid_values_with_wanted_resolution: `VoxelGridValuesBase` to whose resolution
          to interpolate grid_values
      align_corners: as for torch.nn.functional.interpolate
      mode: as for torch.nn.functional.interpolate
          'nearest' | 'bicubic' | 'linear' | 'area' | 'nearest-exact'.
          Default: 'linear'
      antialias: as for torch.nn.functional.interpolate.
           Using anti-alias option
           together with align_corners=False and mode='bicubic', interpolation
           result would match Pillow result for downsampling operation.
           Supported mode: 'bicubic'
  Returns:
      tuple of
          - new voxel grid_values of desired resolution, of type self.values_type
          - True if regridding has happened.
docstr_tok: ["Changes","resolution","of","tensors","in","`","grid_values","`","to","match","the","`","grid_values_with_wanted_resolution","`","or","resolution","on","wanted","epoch",".","Args",":","epoch",":","current","training","epoch",",","used","to","see","if","the","grid","needs","regridding","grid_values",":","instance","of","self.values_type","which","contains","the","voxel","grid","which","will","be","interpolated","to","create","the","new","grid","epoch",":","epoch","which","is","used","to","get","the","resolution","of","the","new","`","grid_values","`","using","`","self.resolution_changes","`",".","grid_values_with_wanted_resolution",":","`","VoxelGridValuesBase","`","to","whose","resolution","to","interpolate","grid_values","align_corners",":","as","for","torch.nn.functional.interpolate","mode",":","as","for","torch.nn.functional.interpolate","'nearest","'","|","'bicubic","'","|","'linear","'","|","'area","'","|","'nearest-exact","'",".","Default",":","'linear'","antialias",":","as","for","torch.nn.functional.interpolate",".","Using","anti-alias","option","together","with","align_corners=False","and","mode='bicubic","'",",","interpolation","result","would","match","Pillow","result","for","downsampling","operation",".","Supported","mode",":","'bicubic'","Returns",":","tuple","of","-","new","voxel","grid_values","of","desired","resolution",",","of","type","self.values_type","-","True","if","regridding","has","happened","."]
code: def change_resolution(
      self,
      grid_values: VoxelGridValuesBase,
      *,
      epoch: Optional[int] = None,
      grid_values_with_wanted_resolution: Optional[
          VoxelGridValuesBase
      ] = None,
      mode: str = "linear",
      align_corners: bool = True,
      antialias: bool = False,
  ) -> Tuple[VoxelGridValuesBase, bool]:
      """
      Changes resolution of tensors in `grid_values` to match the
      `grid_values_with_wanted_resolution` or resolution on wanted epoch.
  
      Args:
          epoch: current training epoch, used to see if the grid needs regridding
          grid_values: instance of self.values_type which contains
              the voxel grid which will be interpolated to create the new grid
          epoch: epoch which is used to get the resolution of the new
              `grid_values` using `self.resolution_changes`.
          grid_values_with_wanted_resolution: `VoxelGridValuesBase` to whose resolution
              to interpolate grid_values
          align_corners: as for torch.nn.functional.interpolate
          mode: as for torch.nn.functional.interpolate
              'nearest' | 'bicubic' | 'linear' | 'area' | 'nearest-exact'.
              Default: 'linear'
          antialias: as for torch.nn.functional.interpolate.
               Using anti-alias option
               together with align_corners=False and mode='bicubic', interpolation
               result would match Pillow result for downsampling operation.
               Supported mode: 'bicubic'
      Returns:
          tuple of
              - new voxel grid_values of desired resolution, of type self.values_type
              - True if regridding has happened.
      """
  
      if (epoch is None) == (
          grid_values_with_wanted_resolution is None
      ):
          raise ValueError(
              "Exactly one of `epoch` or "
              "`grid_values_with_wanted_resolution` has to be defined."
          )
  
      if mode not in (
          "nearest",
          "bicubic",
          "linear",
          "area",
          "nearest-exact",
      ):
          raise ValueError(
              "`mode` should be one of the following 'nearest'"
              + "| 'bicubic' | 'linear' | 'area' | 'nearest-exact'"
          )
  
      interpolate_has_antialias = (
          LooseVersion(torch.__version__) >= "1.11"
      )
  
      if antialias and not interpolate_has_antialias:
          warnings.warn(
              "Antialiased interpolation requires PyTorch 1.11+; ignoring"
          )
  
      interp_kwargs = (
          {"antialias": antialias} if interpolate_has_antialias else {}
      )
  
      def change_individual_resolution(tensor, wanted_resolution):
          if mode == "linear":
              n_dim = len(wanted_resolution)
              new_mode = ("linear", "bilinear", "trilinear")[n_dim - 1]
          else:
              new_mode = mode
          return torch.nn.functional.interpolate(
              input=tensor,
              size=wanted_resolution,
              mode=new_mode,
              align_corners=align_corners,
              recompute_scale_factor=False,
              **interp_kwargs,
          )
  
      if epoch is not None:
          if epoch not in self.resolution_changes:
              return grid_values, False
  
          wanted_shapes = self.get_shapes(epoch=epoch)
          params = {
              name: change_individual_resolution(
                  getattr(grid_values, name), shape[1:]
              )
              for name, shape in wanted_shapes.items()
          }
          res = self.get_resolution(epoch)
          logger.info(
              f"Changed grid resolutiuon at epoch {epoch} to {res}"
          )
      else:
          params = {
              name: (
                  change_individual_resolution(
                      getattr(grid_values, name), tensor.shape[2:]
                  )
                  if tensor is not None
                  else None
              )
              for name, tensor in vars(
                  grid_values_with_wanted_resolution
              ).items()
          }
  
      return self.values_type(**params), True
  
imports: import logging
  import warnings
  from collections.abc import Mapping
  from dataclasses import dataclass, field
  from distutils.version import LooseVersion
  from typing import Any, Callable, ClassVar, Dict, Iterator, List, Optional, Tuple, Type
  import torch
  from omegaconf import DictConfig
  from pytorch3d.implicitron.tools.config import Configurable, registry, ReplaceableBase, run_auto_creation
  from pytorch3d.structures.volumes import VolumeLocator
  from .utils import interpolate_line, interpolate_plane, interpolate_volume
label_desc: Use image node_id 7 for calling the VoxelGridBase obj's underlying member method code with example usage: obj.change_resolution(grid_values) and returns: self,  True, torch, grid_values,  False