code: def compute_radii(
      cameras: CamerasBase,
      xy_grid: torch.Tensor,
      pixel_hw_ndc: Tuple[float, float],
  ) -> torch.Tensor:
      """
      Compute radii of conical frustums in world coordinates.
  
      Args:
          cameras: cameras object representing a batch of cameras.
          xy_grid: torch.tensor grid of image xy coords.
          pixel_hw_ndc: pixel height and width in NDC
  
      Returns:
          radii: A tensor of shape `(..., 1)` radii of a cone.
      """
      batch_size = xy_grid.shape[0]
      spatial_size = xy_grid.shape[1:-1]
      n_rays_per_image = spatial_size.numel()
  
      xy = xy_grid.view(batch_size, n_rays_per_image, 2)
  
      # [batch_size, 3 * n_rays_per_image, 2]
      xy = torch.cat(
          [
              xy,
              # Will allow to find the norm on the x axis
              xy + torch.tensor([pixel_hw_ndc[1], 0], device=xy.device),
              # Will allow to find the norm on the y axis
              xy + torch.tensor([0, pixel_hw_ndc[0]], device=xy.device),
          ],
          dim=1,
      )
      # [batch_size, 3 * n_rays_per_image, 3]
      xyz = torch.cat(
          (
              xy,
              xy.new_ones(batch_size, 3 * n_rays_per_image, 1),
          ),
          dim=-1,
      )
  
      # unproject the points
      unprojected_xyz = cameras.unproject_points(xyz, from_ndc=True)
  
      plane_world, plane_world_dx, plane_world_dy = torch.split(
          unprojected_xyz, n_rays_per_image, dim=1
      )
  
      # Distance from each unit-norm direction vector to its neighbors.
      dx_norm = torch.linalg.norm(
          plane_world_dx - plane_world, dim=-1, keepdims=True
      )
      dy_norm = torch.linalg.norm(
          plane_world_dy - plane_world, dim=-1, keepdims=True
      )
      # Cut the distance in half to obtain the base radius: (dx_norm + dy_norm) * 0.5
      # Scale it by 2/12**0.5 to match the variance of the pixel’s footprint
      radii = (dx_norm + dy_norm) / 12**0.5
  
      return radii.view(batch_size, *spatial_size, 1)
  
imports: from typing import Optional, Tuple
  import torch
  from pytorch3d.implicitron.tools import camera_utils
  from pytorch3d.implicitron.tools.config import registry, ReplaceableBase
  from pytorch3d.renderer import NDCMultinomialRaysampler
  from pytorch3d.renderer.cameras import CamerasBase
  from pytorch3d.renderer.implicit.utils import HeterogeneousRayBundle
  from .base import EvaluationMode, ImplicitronRayBundle, RenderSamplingMode
label_desc: Use image node_id 1 for calling a global function with example usage: compute_radii(cameras, xy_grid, pixel_hw_ndc) and returns: radii