code: def _fast_region(x, y, dist, radius=0):
      if not isinstance(radius, (int, np.integer)):
          raise TypeError("'radius' must be an integer.")
      if radius < 0:
          raise ValueError("'radius' must be a non-negative integer.")
      n_timestamps_1, n_timestamps_2 = len(x), len(y)
      min_size = radius + 2
      region = None
      n_timestamps = min(n_timestamps_1, n_timestamps_2)
      if n_timestamps > min_size:
          n_recursions = ceil(log2(n_timestamps / min_size))
          for i in range(n_recursions):
              resolution = 2 ** (n_recursions - i)
              remainder_1 = n_timestamps_1 % resolution
              remainder_2 = n_timestamps_2 % resolution
  
              if remainder_1 != 0:
                  x_padded = np.append(
                      x, np.repeat(x[-1], resolution - remainder_1)
                  )
                  x_padded = x_padded.reshape(-1, resolution).mean(
                      axis=1
                  )
              else:
                  x_padded = x.reshape(-1, resolution).mean(axis=1)
              if remainder_2 != 0:
                  y_padded = np.append(
                      y, np.repeat(y[-1], resolution - remainder_2)
                  )
                  y_padded = y_padded.reshape(-1, resolution).mean(
                      axis=1
                  )
              else:
                  y_padded = y.reshape(-1, resolution).mean(axis=1)
  
              cost_mat_res = cost_matrix(
                  x_padded, y_padded, dist=dist, region=region
              )
              acc_cost_mat_res = accumulated_cost_matrix(
                  cost_mat_res, region=region
              )
              path_res = _return_path(acc_cost_mat_res)
              n_timestamps_next_1 = ceil(
                  (2 * n_timestamps_1) / resolution
              )
              n_timestamps_next_2 = ceil(
                  (2 * n_timestamps_2) / resolution
              )
  
              region = _blurred_path_region(
                  n_timestamps_next_1,
                  n_timestamps_next_2,
                  2,
                  x_padded.size,
                  y_padded.size,
                  path_res,
                  radius,
              )
  
      return region
  
imports: import numpy
  from math import ceil, log2, sqrt
  from numba import njit, prange
  from sklearn.utils import check_array
label_desc: Use image node_id 25 for calling a global function with example usage: _fast_region(x, y, dist, radius) and returns: region