code: def compute_pixel_radii_from_grid(
      pixel_grid: torch.Tensor,
  ) -> torch.Tensor:
      """
      Compute the radii of a conical frustum given the pixel grid.
  
      To compute the radii we first compute the translation from a pixel
      to its neighbors along the x and y axis. Then, we compute the norm
      of each translation along the x and y axis.
      The radii are then obtained by the following formula:
  
      (dx_norm + dy_norm) * 0.5 * 2 / 12**0.5
  
      where 2/12**0.5 is a scaling factor to match
      the variance of the pixel’s footprint.
  
      Args:
          pixel_grid: A tensor of shape `(..., H, W, dim)` representing the
              full grid of rays pixel_grid.
  
      Returns:
          The radiis for each pixels and shape `(..., H, W, 1)`.
      """
      # [B, H, W - 1, 3]
      x_translation = torch.diff(pixel_grid, dim=-2)
      # [B, H - 1, W, 3]
      y_translation = torch.diff(pixel_grid, dim=-3)
      # [B, H, W - 1, 1]
      dx_norm = torch.linalg.norm(x_translation, dim=-1, keepdim=True)
      # [B, H - 1, W, 1]
      dy_norm = torch.linalg.norm(y_translation, dim=-1, keepdim=True)
  
      # Fill the missing value [B, H, W, 1]
      dx_norm = torch.concatenate([dx_norm, dx_norm[..., -1:, :]], -2)
      dy_norm = torch.concatenate(
          [dy_norm, dy_norm[..., -1:, :, :]], -3
      )
  
      # Cut the distance in half to obtain the base radius: (dx_norm + dy_norm) * 0.5
      # and multiply it by the scaling factor: * 2 / 12**0.5
      radii = (dx_norm + dy_norm) / 12**0.5
      return radii
  
imports: import unittest
  from itertools import product
  from typing import Tuple
  from unittest.mock import patch
  import torch
  from pytorch3d.common.compat import meshgrid_ij
  from pytorch3d.implicitron.models.renderer.base import EvaluationMode
  from pytorch3d.implicitron.models.renderer.ray_sampler import AdaptiveRaySampler, compute_radii, NearFarRaySampler
  from pytorch3d.renderer.cameras import CamerasBase, FoVOrthographicCameras, FoVPerspectiveCameras, OrthographicCameras, PerspectiveCameras
  from pytorch3d.renderer.implicit.utils import HeterogeneousRayBundle
  from tests.common_camera_utils import init_random_cameras
  from tests.common_testing import TestCaseMixin
label_desc: Use image node_id 2 for calling a global function with example usage: compute_pixel_radii_from_grid(pixel_grid) and returns: radii