code: def _modified_bessel_i(n: int, x: Tensor) -> Tensor:
      r"""Adapted from:
  
      https://github.com/Project-MONAI/MONAI/blob/master/monai/networks/layers/convutils.py
      """
      KORNIA_CHECK(n >= 2, "n must be greater than 1.99")
  
      if (x == 0.0).all():
          return x
  
      batch_size = x.shape[0]
  
      tox = 2.0 / x.abs()
      ans = zeros(batch_size, 1, device=x.device, dtype=x.dtype)
      bip = zeros(batch_size, 1, device=x.device, dtype=x.dtype)
      bi = torch.ones(batch_size, 1, device=x.device, dtype=x.dtype)
  
      m = int(2 * (n + int(sqrt(40.0 * n))))
      for j in range(m, 0, -1):
          bim = bip + float(j) * tox * bi
          bip = bi
          bi = bim
          idx = bi.abs() > 1.0e10
  
          if idx.any():
              ans[idx] = ans[idx] * 1.0e-10
              bi[idx] = bi[idx] * 1.0e-10
              bip[idx] = bip[idx] * 1.0e-10
  
          if j == n:
              ans = bip
  
      out = ans * _modified_bessel_0(x) / bi
  
      if (n % 2) == 1:
          out = where(x < 0.0, -out, out)
  
      # TODO: skip the previous computation for x == 0, instead of forcing here
      out = where(x == 0.0, x, out)
  
      return out
  
imports: from __future__ import annotations
  import math
  from math import sqrt
  from typing import Any, Optional
  import torch
  from kornia.core import Device, Dtype, Tensor, concatenate, cos, stack, tensor, where, zeros, zeros_like
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_IS_TENSOR, KORNIA_CHECK_SHAPE
  from kornia.utils import deprecated
label_desc: Use image node_id 9 for calling a global function with example usage: _modified_bessel_i(n, x) and returns: out, x