code: def from_df(
      df,
      static_df=None,
      sort_df=False,
      id_col="unique_id",
      time_col="ds",
      target_col="y",
  ):
      # TODO: protect on equality of static_df + df indexes
      if isinstance(df, pd.DataFrame) and df.index.name == id_col:
          warnings.warn(
              "Passing the id as index is deprecated, please provide it as a column instead.",
              FutureWarning,
          )
          df = df.reset_index(id_col)
      # Define indexes if not given
      if static_df is not None:
          if (
              isinstance(static_df, pd.DataFrame)
              and static_df.index.name == id_col
          ):
              warnings.warn(
                  "Passing the id as index is deprecated, please provide it as a column instead.",
                  FutureWarning,
              )
          if sort_df:
              static_df = ufp.sort(static_df, by=id_col)
  
      ids, times, data, indptr, sort_idxs = ufp.process_df(
          df, id_col, time_col, target_col
      )
      # processor sets y as the first column
      temporal_cols = pd.Index(
          [target_col]
          + [
              c
              for c in df.columns
              if c not in (id_col, time_col, target_col)
          ]
      )
      temporal = data.astype(np.float32, copy=False)
      indices = ids
      if isinstance(df, pd.DataFrame):
          dates = pd.Index(times, name=time_col)
      else:
          dates = pl_Series(time_col, times)
      sizes = np.diff(indptr)
      max_size = max(sizes)
      min_size = min(sizes)
  
      # Add Available mask efficiently (without adding column to df)
      if "available_mask" not in df.columns:
          available_mask = np.ones((len(temporal), 1), dtype=np.float32)
          temporal = np.append(temporal, available_mask, axis=1)
          temporal_cols = temporal_cols.append(
              pd.Index(["available_mask"])
          )
  
      # Static features
      if static_df is not None:
          static_cols = static_df.columns.drop(id_col)
          static = ufp.to_numpy(static_df[static_cols])
      else:
          static = None
          static_cols = None
  
      dataset = TimeSeriesDataset(
          temporal=temporal,
          temporal_cols=temporal_cols,
          static=static,
          static_cols=static_cols,
          indptr=indptr,
          max_size=max_size,
          min_size=min_size,
          sorted=sort_df,
          y_idx=0,
      )
      ds = df[time_col].to_numpy()
      if sort_idxs is not None:
          ds = ds[sort_idxs]
      return dataset, indices, dates, ds
  
imports: import warnings
  from collections.abc import Mapping
  import numpy
  import pandas
  import pytorch_lightning
  import torch
  import utilsforecast.processing
  from torch.utils.data import Dataset, DataLoader
  from utilsforecast.compat import DataFrame, pl_Series
label_desc: Use image node_id 10 for calling the TimeSeriesDataset obj's underlying member method code with example usage: obj.from_df(df, static_df, sort_df, id_col, time_col, target_col) and returns: dataset,  indices,  dates,  ds