code: def add_missing_dates_nan(df, freq):
      """Fills missing datetimes in ``ds``, with NaN for all other columns except ``ID``.
  
      Parameters
      ----------
          df : pd.Dataframe
              with column ``ds``  datetimes
          freq : str
              Frequency of data recording, any valid frequency for pd.date_range,
              such as ``D`` or ``M``
  
      Returns
      -------
          pd.DataFrame
              dataframe without date-gaps but nan-values
      """
      df["ds"] = pd.to_datetime(df["ds"])
      df = df.set_index("ds")
      df_resampled = df.resample(freq).asfreq()
      if "ID" in df.columns:
          df_resampled["ID"].fillna(df["ID"].iloc[0], inplace=True)
      df_resampled.reset_index(inplace=True)
  
      num_added = len(df_resampled) - len(df)
      return df_resampled, num_added
  
imports: from __future__ import annotations
  import logging
  import math
  from collections import OrderedDict
  from dataclasses import dataclass
  from typing import TYPE_CHECKING, List, Optional, Tuple
  import numpy
  import pandas
label_desc: Use image node_id 22 for calling a global function with example usage: add_missing_dates_nan(df, freq) and returns: df_resampled,  num_added