code: def update_from_schema(cfg, cfgin, schema):
      
      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
docs: 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