[notebook] Use export hints if a .py is automatically saved

Use metadata of a code cell to determine if this cell should be
automatically saved into a .py file.

This is helpful if you want to import functions/classes defined in
this notebook, but the notebook contains magics or running code without
a guard.

Three states can be used: "commented", "omit", and "as_is" (default).

This must be enabled by passing "--use-export-hints" to the notebook
command in addition to "--script".

Closes #3295