code: def _radial_and_tangential_undistort(
      xd: np.ndarray,
      yd: np.ndarray,
      k1: float = 0,
      k2: float = 0,
      k3: float = 0,
      p1: float = 0,
      p2: float = 0,
      eps: float = 1e-9,
      max_iterations=10,
  ) -> Tuple[np.ndarray, np.ndarray]:
      """Computes undistorted (x, y) from (xd, yd)."""
      # Initialize from the distorted point.
      x = xd.copy()
      y = yd.copy()
  
      for _ in range(max_iterations):
          (
              fx,
              fy,
              fx_x,
              fx_y,
              fy_x,
              fy_y,
          ) = _compute_residual_and_jacobian(
              x=x, y=y, xd=xd, yd=yd, k1=k1, k2=k2, k3=k3, p1=p1, p2=p2
          )
          denominator = fy_x * fx_y - fx_x * fy_y
          x_numerator = fx * fy_y - fy * fx_y
          y_numerator = fy * fx_x - fx * fy_x
          step_x = np.where(
              np.abs(denominator) > eps,
              x_numerator / denominator,
              np.zeros_like(denominator),
          )
          step_y = np.where(
              np.abs(denominator) > eps,
              y_numerator / denominator,
              np.zeros_like(denominator),
          )
  
          x = x + step_x
          y = y + step_y
  
      return x, y
  
imports: import copy
  import json
  from typing import Tuple, Union, Optional
  import numpy
  from nerfies import gpath
  from nerfies import types
label_desc: Use image node_id 2 for calling a global function with example usage: _radial_and_tangential_undistort(xd, yd, k1, k2, k3, p1, p2, eps, max_iterations) and returns: x,  y