src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.ts/getFormattedMetadataJSON
export function getFormattedMetadataJSON(documentTextModel: INotebookTextModel, metadata: NotebookCellMetadata, language?: string) {
	let filteredMetadata: { [key: string]: any } = {};

	if (documentTextModel) {
		const transientCellMetadata = documentTextModel.transientOptions.transientCellMetadata;

		const keys = new Set([...Object.keys(metadata)]);
		for (const key of keys) {
			if (!(transientCellMetadata[key as keyof NotebookCellMetadata])
			) {
				filteredMetadata[key] = metadata[key as keyof NotebookCellMetadata];
			}
		}
	} else {
		filteredMetadata = metadata;
	}

	const obj = {
		language,
		...filteredMetadata
	};

	const metadataSource = toFormattedString(obj, {});

	return metadataSource;
}