code: def _scale_index_to_scale(
      max_coords: Tensor, sigmas: Tensor, num_levels: int
  ) -> Tensor:
      r"""Auxiliary function for ScaleSpaceDetector. Converts scale level index from ConvSoftArgmax3d to the actual
      scale, using the sigmas from the ScalePyramid output.
  
      Args:
          max_coords: tensor [BxNx3].
          sigmas: tensor [BxNxD], D >= 1
  
      Returns:
          tensor [BxNx3].
      """
      # depth (scale) in coord_max is represented as (float) index, not the scale yet.
      # we will interpolate the scale using pytorch.grid_sample function
      # Because grid_sample is for 4d input only, we will create fake 2nd dimension
      # ToDo: replace with 3d input, when grid_sample will start to support it
  
      # Reshape for grid shape
      B, N, _ = max_coords.shape
      scale_coords = max_coords[:, :, 0].contiguous().view(-1, 1, 1, 1)
      # Replace the scale_x_y
      out = concatenate(
          [
              sigmas[0, 0]
              * torch.pow(2.0, scale_coords / float(num_levels)).view(
                  B, N, 1
              ),
              max_coords[:, :, 1:],
          ],
          2,
      )
      return out
  
imports: import math
  from typing import List, Optional, Tuple
  import torch
  import torch.nn.functional
  from typing_extensions import TypedDict
  from kornia.core import Device, Module, Tensor, concatenate, eye, tensor, where, zeros
  from kornia.core.check import KORNIA_CHECK_SHAPE
  from kornia.geometry.subpix import ConvSoftArgmax3d, NonMaximaSuppression2d
  from kornia.geometry.transform import ScalePyramid, pyrdown, resize
  from .laf import laf_from_center_scale_ori, laf_is_inside_image
  from .orientation import PassLAF
  from .responses import BlobHessian
label_desc: Use image node_id 1 for calling a global function with example usage: _scale_index_to_scale(max_coords, sigmas, num_levels) and returns: out