extensions/ipynb/src/serializers.ts/createCodeCellFromNotebookCell
function createCodeCellFromNotebookCell(cell: NotebookCellData, preferredLanguage: string | undefined): nbformat.ICodeCell {
	const cellMetadata = getCellMetadata(cell);
	let metadata = cellMetadata?.metadata || {}; // This cannot be empty.
	if (cell.languageId !== preferredLanguage) {
		metadata = {
			...metadata,
			vscode: {
				languageId: cell.languageId
			}
		};
	} else {
		// cell current language is the same as the preferred cell language in the document, flush the vscode custom language id metadata
		metadata.vscode = undefined;
	}

	const codeCell: any = {
		cell_type: 'code',
		execution_count: cell.executionSummary?.executionOrder ?? null,
		source: splitMultilineString(cell.value.replace(/\r\n/g, '\n')),
		outputs: (cell.outputs || []).map(translateCellDisplayOutput),
		metadata: metadata
	};
	if (cellMetadata?.id) {
		codeCell.id = cellMetadata.id;
	}
	return codeCell;
}