Create WeldObject to encode weld_template code given mapping.

    Parameters
    ----------
    weld_template : str
        Weld code to encode.
    mapping : dict
        Which substitutions to make in the weld_template.

    Returns
    -------
    WeldObject
        Representation of this computation.

def weld_udf(weld_template, mapping):
    """Create WeldObject to encode weld_template code given mapping.

    Parameters
    ----------
    weld_template : str
        Weld code to encode.
    mapping : dict
        Which substitutions to make in the weld_template.

    Returns
    -------
    WeldObject
        Representation of this computation.

    """
    weld_obj = create_empty_weld_object()

    for k, v in mapping.items():
        if isinstance(v, (np.ndarray, WeldObject)):
            obj_id = get_weld_obj_id(weld_obj, v)
            mapping.update({k: obj_id})

    weld_obj.weld_code = weld_template.format(**mapping)

    return weld_obj