code: def drop_missing_from_df(df, drop_missing, predict_steps, n_lags):
      """Drops windows of missing values in df according to the (lagged) samples that are dropped from TimeDataset.
  
      Parameters
      ----------
          df : pd.DataFrame
              dataframe containing column ``ds``, ``y`` with all data
          drop_missing : bool
              identical to NeuralProphet
          n_forecasts : int
              identical to NeuralProphet
          n_lags : int
              identical to NeuralProphet
  
      Returns
      -------
          pd.DataFrame
              dataframe with dropped NaN windows
      """
      if not drop_missing:
          return df
      if n_lags == 0:
          return df
      while pd.isnull(df["y"][:-predict_steps]).any():
          window = []
          all_nan_idx = (
              df[:-predict_steps]
              .loc[df["y"][:-predict_steps].isnull()]
              .index
          )
          if len(all_nan_idx) > 0:
              for i in range(len(all_nan_idx)):
                  window.append(all_nan_idx[i])
                  # last window of NaNs has been detected
                  if all_nan_idx.max() == all_nan_idx[i]:
                      break
                  # detect one NaN window (=consecutive NaNs) at a time
                  if all_nan_idx[i + 1] - all_nan_idx[i] > 1:
                      break
              # drop NaN window
              df = (
                  df.drop(df.index[window[0] : window[-1] + 1])
                  .reset_index()
                  .drop("index", axis=1)
              )
              # drop lagged values if window does not occur at the beginning of df
              if window[0] - (n_lags - 1) >= 0:
                  df = (
                      df.drop(
                          df.index[
                              (window[0] - (n_lags - 1)) : window[0]
                          ]
                      )
                      .reset_index()
                      .drop("index", axis=1)
                  )
      return df
  
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 34 for calling a global function with example usage: drop_missing_from_df(df, drop_missing, predict_steps, n_lags) and returns: df, df, df