code: def ghd(
      ref,
      hyp,
      ins_cost=2.0,
      del_cost=2.0,
      shift_cost_coeff=1.0,
      boundary="1",
  ):
      """
      Compute the Generalized Hamming Distance for a reference and a hypothetical
      segmentation, corresponding to the cost related to the transformation
      of the hypothetical segmentation into the reference segmentation
      through boundary insertion, deletion and shift operations.
  
      A segmentation is any sequence over a vocabulary of two items
      (e.g. "0", "1"), where the specified boundary value is used to
      mark the edge of a segmentation.
  
      Recommended parameter values are a shift_cost_coeff of 2.
      Associated with a ins_cost, and del_cost equal to the mean segment
      length in the reference segmentation.
  
          >>> # Same examples as Kulyukin C++ implementation
          >>> ghd('1100100000', '1100010000', 1.0, 1.0, 0.5)
          0.5
          >>> ghd('1100100000', '1100000001', 1.0, 1.0, 0.5)
          2.0
          >>> ghd('011', '110', 1.0, 1.0, 0.5)
          1.0
          >>> ghd('1', '0', 1.0, 1.0, 0.5)
          1.0
          >>> ghd('111', '000', 1.0, 1.0, 0.5)
          3.0
          >>> ghd('000', '111', 1.0, 2.0, 0.5)
          6.0
  
      :param ref: the reference segmentation
      :type ref: str or list
      :param hyp: the hypothetical segmentation
      :type hyp: str or list
      :param ins_cost: insertion cost
      :type ins_cost: float
      :param del_cost: deletion cost
      :type del_cost: float
      :param shift_cost_coeff: constant used to compute the cost of a shift.
          ``shift cost = shift_cost_coeff * |i - j|`` where ``i`` and ``j``
          are the positions indicating the shift
      :type shift_cost_coeff: float
      :param boundary: boundary value
      :type boundary: str or int or bool
      :rtype: float
      """
  
      ref_idx = [i for (i, val) in enumerate(ref) if val == boundary]
      hyp_idx = [i for (i, val) in enumerate(hyp) if val == boundary]
  
      nref_bound = len(ref_idx)
      nhyp_bound = len(hyp_idx)
  
      if nref_bound == 0 and nhyp_bound == 0:
          return 0.0
      elif nref_bound > 0 and nhyp_bound == 0:
          return nref_bound * ins_cost
      elif nref_bound == 0 and nhyp_bound > 0:
          return nhyp_bound * del_cost
  
      mat = _init_mat(
          nhyp_bound + 1, nref_bound + 1, ins_cost, del_cost
      )
      _ghd_aux(
          mat, hyp_idx, ref_idx, ins_cost, del_cost, shift_cost_coeff
      )
      return mat[-1, -1]
  
label_desc: Use image node_id 4 for calling a global function with example usage: ghd(ref, hyp, ins_cost, del_cost, shift_cost_coeff, boundary) and returns: mat, int, unknown, unknown