code: def _input_to_cost(x, y, dist, precomputed_cost, region):
      """Computes cost matrix from dtw input."""
      if dist == "precomputed":
          if region is not None:
              cost_mat = _project_cost_matrix_region(
                  precomputed_cost, region
              )
          else:
              cost_mat = precomputed_cost.copy()
      else:
          cost_mat = cost_matrix(x, y, dist=dist, region=region)
      cost_mat = check_array(
          cost_mat,
          ensure_min_samples=2,
          ensure_min_features=2,
          ensure_2d=True,
          force_all_finite=False,
          dtype="float64",
      )
      return cost_mat
  
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 7 for calling a global function with example usage: _input_to_cost(x, y, dist, precomputed_cost, region) and returns: cost_mat