class_docstr: Create a PyTorch dataset of a tabularized time-series
class_docstr_tok: ["Create","a","PyTorch","dataset","of","a","tabularized","time-series"]
docstr: Checks if inputs/targets contain any NaN values and drops them, if user opts to.
  Parameters
  ----------
      drop_missing : bool
          whether to automatically drop missing samples from the data
      predict_steps : int
          number of steps to predict
docstr_tok: ["Checks","if","inputs\/targets","contain","any","NaN","values","and","drops","them",",","if","user","opts","to",".","Parameters","--","--","--","--","--","drop_missing",":","bool","whether","to","automatically","drop","missing","samples","from","the","data","predict_steps",":","int","number","of","steps","to","predict"]
code: def drop_nan_after_init(self, df, predict_steps, drop_missing):
      """Checks if inputs/targets contain any NaN values and drops them, if user opts to.
      Parameters
      ----------
          drop_missing : bool
              whether to automatically drop missing samples from the data
          predict_steps : int
              number of steps to predict
      """
      nan_idx = []
      # NaNs in inputs
      for key, data in self.inputs.items():
          if isinstance(data, torch.Tensor):
              nans = torch.where(torch.isnan(data))[0].tolist()
              if len(nans) > 0:
                  nan_idx += nans
          elif isinstance(data, dict):
              for subkey, subdata in data.items():
                  nans = torch.where(torch.isnan(subdata))[0].tolist()
                  if len(nans) > 0:
                      nan_idx += nans
  
      # NaNs in targets that are not inserted for prediction at the end
      nans = torch.where(torch.isnan(self.targets))[0].tolist()
      if len(nans) > 0:
          for idx in nans:
              if idx not in nan_idx and idx < len(self) - predict_steps:
                  nan_idx.append(idx)
  
      nan_idx = list(set(nan_idx))
      nan_idx.sort()
      if drop_missing and len(nan_idx) > 0:
          log.warning(
              f"{len(nan_idx)} samples with missing values were dropped from the data. "
          )
          for key, data in self.inputs.items():
              if key not in ["time", "lags"]:  # "time_lagged"
                  for name, features in data.items():
                      self.inputs[key][name] = np.delete(
                          self.inputs[key][name], nan_idx, 0
                      )
              else:
                  self.inputs[key] = np.delete(
                      self.inputs[key], nan_idx, 0
                  )
          self.targets = np.delete(self.targets, nan_idx, 0)
          self.length = self.inputs["time"].shape[0]
      if not drop_missing and len(nan_idx) > 0:
          raise ValueError(
              "Inputs/targets with missing values detected. "
              "Please either adjust imputation parameters, or set 'drop_missing' to True to drop those samples."
          )
  
imports: import logging
  from collections import OrderedDict, defaultdict
  from datetime import datetime
  from typing import Optional
  import numpy
  import pandas
  import torch
  from torch.utils.data.dataset import Dataset
  from neuralprophet import configure, utils
  from neuralprophet.df_utils import get_max_num_lags
  from neuralprophet.hdays_utils import get_country_holidays
label_desc: Use image node_id 2 for calling the TimeDataset obj's underlying member method code with example usage: obj.drop_nan_after_init(df, predict_steps, drop_missing) without return types