<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(new_directory, clean_up=lambda: True):
 # pylint: disable=invalid-name """Changes into a given directory and cleans up after it is done Args: new_directory: The directory to change to clean_up: A method to clean up the working directory once done """

    previous_directory = os.getcwd()
    os.chdir(os.path.expanduser(new_directory))
    try:
        yield
    finally:
        os.chdir(previous_directory)
        clean_up()