<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ipynb_to_rst(directory, filename):
 """Converts a given file in a directory to an rst in the same directory."""

    print(filename)
    os.chdir(directory)
    subprocess.Popen(["ipython", "nbconvert", "--to", "rst",
                      filename],
                     stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
                     cwd=directory)