<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def upsert(path, value, create_parents=False, **kwargs):
 """ Create or replace a dictionary path. :param path: The path to modify :param value: The new value for the path. This should be a native Python object which can be encoded into JSON (the SDK will do the encoding for you). :param create_parents: Whether intermediate parents should be created. This means creating any additional levels of hierarchy not already in the document, for example: .. code-block:: python {'foo': {}} Without `create_parents`, an operation such as .. code-block:: python cb.mutate_in("docid", SD.upsert("foo.bar.baz", "newValue")) would fail with :cb_exc:`SubdocPathNotFoundError` because `foo.bar` does not exist. However when using the `create_parents` option, the server creates the new `foo.bar` dictionary and then inserts the `baz` value. """

    return _gen_4spec(LCB_SDCMD_DICT_UPSERT, path, value,
                      create_path=create_parents, **kwargs)