<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_from_schema(cfg, cfgin, schema):
 """Update configuration dictionary ``cfg`` with the contents of ``cfgin`` using the ``schema`` dictionary to determine the valid input keys. Parameters cfg : dict Configuration dictionary to be updated. cfgin : dict New configuration dictionary that will be merged with ``cfg``. schema : dict Configuration schema defining the valid configuration keys and their types. Returns ------- cfgout : dict """

    cfgout = copy.deepcopy(cfg)
    for k, v in schema.items():

        if k not in cfgin:
            continue
        if isinstance(v, dict):
            cfgout.setdefault(k, {})
            cfgout[k] = update_from_schema(cfg[k], cfgin[k], v)
        elif v[2] is dict:
            cfgout[k] = utils.merge_dict(cfg[k], cfgin[k], add_new_keys=True)
        else:
            cfgout[k] = cfgin[k]

    return cfgout