docstr: Fit the core.NeuralForecast.
  
  Fit `models` to a large set of time series from DataFrame `df`.
  and store fitted models for later inspection.
  
  Parameters
  ----------
  df : pandas or polars DataFrame, optional (default=None)
      DataFrame with columns [`unique_id`, `ds`, `y`] and exogenous variables.
      If None, a previously stored dataset is required.
  static_df : pandas or polars DataFrame, optional (default=None)
      DataFrame with columns [`unique_id`] and static exogenous.
  val_size : int, optional (default=0)
      Size of validation set.
  sort_df : bool, optional (default=False)
      Sort `df` before fitting.
  use_init_models : bool, optional (default=False)
      Use initial model passed when NeuralForecast object was instantiated.
  verbose : bool (default=False)
      Print processing steps.
  id_col : str (default='unique_id')
      Column that identifies each serie.
  time_col : str (default='ds')
      Column that identifies each timestep, its values can be timestamps or integers.
  target_col : str (default='y')
      Column that contains the target.
  
  Returns
  -------
  self : NeuralForecast
      Returns `NeuralForecast` class with fitted `models`.
docstr_tok: ["Fit","the","core.NeuralForecast",".","Fit","`","models","`","to","a","large","set","of","time","series","from","DataFrame","`","df","`",".","and","store","fitted","models","for","later","inspection",".","Parameters","--","--","--","--","--","df",":","pandas","or","polars","DataFrame",",","optional","(","default=None",")","DataFrame","with","columns","[","`","unique_id","`",",","`","ds","`",",","`","y","`","]","and","exogenous","variables",".","If","None",",","a","previously","stored","dataset","is","required",".","static_df",":","pandas","or","polars","DataFrame",",","optional","(","default=None",")","DataFrame","with","columns","[","`","unique_id","`","]","and","static","exogenous",".","val_size",":","int",",","optional","(","default=0",")","Size","of","validation","set",".","sort_df",":","bool",",","optional","(","default=False",")","Sort","`","df","`","before","fitting",".","use_init_models",":","bool",",","optional","(","default=False",")","Use","initial","model","passed","when","NeuralForecast","object","was","instantiated",".","verbose",":","bool","(","default=False",")","Print","processing","steps",".","id_col",":","str","(","default='unique_id","'",")","Column","that","identifies","each","serie",".","time_col",":","str","(","default='ds","'",")","Column","that","identifies","each","timestep",",","its","values","can","be","timestamps","or","integers",".","target_col",":","str","(","default=","'","y","'",")","Column","that","contains","the","target",".","Returns","--","--","--","-","self",":","NeuralForecast","Returns","`","NeuralForecast","`","class","with","fitted","`","models","`","."]
code: def fit(
      self,
      df: Optional[DataFrame] = None,
      static_df: Optional[DataFrame] = None,
      val_size: Optional[int] = 0,
      sort_df: bool = True,
      use_init_models: bool = False,
      verbose: bool = False,
      id_col: str = "unique_id",
      time_col: str = "ds",
      target_col: str = "y",
  ) -> None:
      """Fit the core.NeuralForecast.
  
      Fit `models` to a large set of time series from DataFrame `df`.
      and store fitted models for later inspection.
  
      Parameters
      ----------
      df : pandas or polars DataFrame, optional (default=None)
          DataFrame with columns [`unique_id`, `ds`, `y`] and exogenous variables.
          If None, a previously stored dataset is required.
      static_df : pandas or polars DataFrame, optional (default=None)
          DataFrame with columns [`unique_id`] and static exogenous.
      val_size : int, optional (default=0)
          Size of validation set.
      sort_df : bool, optional (default=False)
          Sort `df` before fitting.
      use_init_models : bool, optional (default=False)
          Use initial model passed when NeuralForecast object was instantiated.
      verbose : bool (default=False)
          Print processing steps.
      id_col : str (default='unique_id')
          Column that identifies each serie.
      time_col : str (default='ds')
          Column that identifies each timestep, its values can be timestamps or integers.
      target_col : str (default='y')
          Column that contains the target.
  
      Returns
      -------
      self : NeuralForecast
          Returns `NeuralForecast` class with fitted `models`.
      """
      if (df is None) and not (hasattr(self, "dataset")):
          raise Exception(
              "You must pass a DataFrame or have one stored."
          )
  
      # Model and datasets interactions protections
      if (
          any(
              model.early_stop_patience_steps > 0
              for model in self.models
          )
      ) and (val_size == 0):
          raise Exception(
              "Set val_size>0 if early stopping is enabled."
          )
  
      # Process and save new dataset (in self)
      if df is not None:
          validate_freq(df[time_col], self.freq)
          (
              self.dataset,
              self.uids,
              self.last_dates,
              self.ds,
          ) = self._prepare_fit(
              df=df,
              static_df=static_df,
              sort_df=sort_df,
              predict_only=False,
              id_col=id_col,
              time_col=time_col,
              target_col=target_col,
          )
          self.sort_df = sort_df
      else:
          if verbose:
              print("Using stored dataset.")
  
      if val_size is not None:
          if self.dataset.min_size < val_size:
              warnings.warn(
                  "Validation set size is larger than the shorter time-series."
              )
  
      # Recover initial model if use_init_models
      if use_init_models:
          self._reset_models()
  
      for model in self.models:
          model.fit(self.dataset, val_size=val_size)
  
      self._fitted = True
  
imports: import os
  import pickle
  import warnings
  from copy import deepcopy
  from itertools import chain
  from typing import Any, Dict, List, Optional, Union
  import numpy
  import pandas
  import torch
  import utilsforecast.processing
  from utilsforecast.compat import DataFrame, Series, pl_DataFrame, pl_Series
  from utilsforecast.grouped_array import GroupedArray
  from utilsforecast.target_transforms import BaseTargetTransform, LocalBoxCox, LocalMinMaxScaler, LocalRobustScaler, LocalStandardScaler
  from utilsforecast.validation import validate_freq
  from .tsdataset import TimeSeriesDataset
  from neuralforecast.models import GRU, LSTM, RNN, TCN, DeepAR, DilatedRNN, MLP, NHITS, NBEATS, NBEATSx, TFT, VanillaTransformer, Informer, Autoformer, FEDformer, StemGNN, PatchTST, TimesNet
label_desc: Use image node_id 6 for calling the NeuralForecast obj's underlying member method code with example usage: obj.fit(df, static_df, val_size, sort_df, use_init_models, verbose, id_col, time_col, target_col) without return types