def prepare_notebook_metadata(nb, input_path, output_path, report_mode=False):
<EOL>nb = copy.deepcopy(nb)<EOL>if report_mode:<EOL><INDENT>for cell in nb.cells:<EOL><INDENT>if cell.cell_type == '<STR_LIT:code>':<EOL><INDENT>cell.metadata['<STR_LIT>'] = cell.get('<STR_LIT>', {})<EOL>cell.metadata['<STR_LIT>']['<STR_LIT>'] = True<EOL><DEDENT><DEDENT><DEDENT>nb.metadata.papermill['<STR_LIT>'] = input_path<EOL>nb.metadata.papermill['<STR_LIT>'] = output_path<EOL>return nb<EOL>
Prepare metadata associated with a notebook and its cells

    Parameters
    ----------
    nb : NotebookNode
       Executable notebook object
    input_path : str
        Path to input notebook
    output_path : str
       Path to write executed notebook
    report_mode : bool, optional
       Flag to set report mode