<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cd(path):
 """Context manager to temporarily change working directories :param str path: The directory to move into '/home/user/code/myrepo' Changed directory: /home/user/code/otherdir/subdir '/home/user/code/myrepo' """

    if not path:
        return
    prev_cwd = Path.cwd().as_posix()
    if isinstance(path, Path):
        path = path.as_posix()
    os.chdir(str(path))
    try:
        yield
    finally:
        os.chdir(prev_cwd)