code: def _fast_dtw(
      x: np.ndarray,
      y: np.ndarray,
      dist: DistanceFunc,
      radius: int,
      depth: int = 0,
  ) -> CostMatrix:
      n = len(x)
      m = len(y)
      min_size = radius + 2
  
      if n < min_size or m < min_size or radius == -1:
          window = NoWindow()
          window.init_size(n, m)
          cost = _dtw_cost_matrix(x, y, dist, window)
  
          return cost
  
      half_x = _down_sample(x)
      half_y = _down_sample(y)
  
      low_res_cost = _fast_dtw(half_x, half_y, dist, radius, depth + 1)
      low_res_path = _dtw_path(low_res_cost)
      window = _expand_window(low_res_path, len(x), len(y), radius)
      cost = _dtw_cost_matrix(x, y, dist, window)
  
      return cost
  
imports: import copy
  from typing import Callable, Optional, Union
  import numpy
  import pandas
  import xarray
  from darts import TimeSeries
  from darts.logging import get_logger, raise_if, raise_if_not
  from darts.timeseries import DIMS
  from .cost_matrix import CostMatrix
  from .window import CRWindow, NoWindow, Window
label_desc: Use image node_id 5 for calling a global function with example usage: _fast_dtw(x, y, dist, radius, depth) and returns: cost, cost