code: def merge_curves(curves, start, n):
      """Give a cubic-Bezier spline, reconstruct one cubic-Bezier
      that has the same endpoints and tangents and approxmates
      the spline."""
  
      # Reconstruct the t values of the cut segments
      prod_ratio = 1.0
      sum_ratio = 1.0
      ts = [1]
      for k in range(1, n):
          ck = curves[start + k]
          c_before = curves[start + k - 1]
  
          # |t_(k+1) - t_k| / |t_k - t_(k - 1)| = ratio
          assert ck[0] == c_before[3]
          ratio = abs(ck[1] - ck[0]) / abs(c_before[3] - c_before[2])
  
          prod_ratio *= ratio
          sum_ratio += prod_ratio
          ts.append(sum_ratio)
  
      # (t(n) - t(n - 1)) / (t_(1) - t(0)) = prod_ratio
  
      ts = [t / sum_ratio for t in ts[:-1]]
  
      p0 = curves[start][0]
      p1 = curves[start][1]
      p2 = curves[start + n - 1][2]
      p3 = curves[start + n - 1][3]
  
      # Build the curve by scaling the control-points.
      p1 = p0 + (p1 - p0) / (ts[0] if ts else 1)
      p2 = p3 + (p2 - p3) / ((1 - ts[-1]) if ts else 1)
  
      curve = (p0, p1, p2, p3)
  
      return curve, ts
  
file_path: catboost/contrib/python/fonttools/fontTools/qu2cu/qu2cu.py
imports: from fontTools.misc.bezierTools import splitCubicAtTC
  from collections import namedtuple
  import math
  from typing import List, Tuple, Union
label_desc: Use image node_id 3 for calling a global function with example usage: merge_curves(curves, start, n) and returns: curve,  ts