docstr: predict dataloader
  
  Args:
      dataloader: dataloader, dataframe or dataset
      mode: one of "prediction", "quantiles", "samples" or "raw", or tuple ``("raw", output_name)`` where
          output_name is a name in the dictionary returned by ``forward()``
      return_index: if to return the prediction index (in the same order as the output, i.e. the row of the
          dataframe corresponds to the first dimension of the output and the given time index is the time index
          of the first prediction)
      return_decoder_lengths: if to return decoder_lengths (in the same order as the output
      batch_size: batch size for dataloader - only used if data is not a dataloader is passed
      num_workers: number of workers for dataloader - only used if data is not a dataloader is passed
      fast_dev_run: if to only return results of first batch
      show_progress_bar: if to show progress bar. Defaults to False.
      return_x: if to return network inputs (in the same order as prediction output)
      return_y: if to return network targets (in the same order as prediction output)
      mode_kwargs (Dict[str, Any]): keyword arguments for ``to_prediction()`` or ``to_quantiles()``
          for modes "prediction" and "quantiles"
      trainer_kwargs (Dict[str, Any], optional): keyword arguments for the trainer
      write_interval: interval to write predictions to disk
      output_dir: directory to write predictions to. Defaults to None. If set function will return empty list
      n_samples: number of samples to draw. Defaults to 100.
  
  Returns:
      Prediction: if one of the ```return`` arguments is present,
          prediction tuple with fields ``prediction``, ``x``, ``y``, ``index`` and ``decoder_lengths``
docstr_tok: ["predict","dataloader","Args",":","dataloader",":","dataloader",",","dataframe","or","dataset","mode",":","one","of","``","prediction","''",",","``","quantiles","''",",","``","samples","''","or","``","raw","''",",","or","tuple","``","(","``","raw","''",",","output_name",")","``","where","output_name","is","a","name","in","the","dictionary","returned","by","``","forward","(",")","``","return_index",":","if","to","return","the","prediction","index","(","in","the","same","order","as","the","output",",","i.e",".","the","row","of","the","dataframe","corresponds","to","the","first","dimension","of","the","output","and","the","given","time","index","is","the","time","index","of","the","first","prediction",")","return_decoder_lengths",":","if","to","return","decoder_lengths","(","in","the","same","order","as","the","output","batch_size",":","batch","size","for","dataloader","-","only","used","if","data","is","not","a","dataloader","is","passed","num_workers",":","number","of","workers","for","dataloader","-","only","used","if","data","is","not","a","dataloader","is","passed","fast_dev_run",":","if","to","only","return","results","of","first","batch","show_progress_bar",":","if","to","show","progress","bar",".","Defaults","to","False",".","return_x",":","if","to","return","network","inputs","(","in","the","same","order","as","prediction","output",")","return_y",":","if","to","return","network","targets","(","in","the","same","order","as","prediction","output",")","mode_kwargs","(","Dict","[","str",",","Any","]",")",":","keyword","arguments","for","``","to_prediction","(",")","``","or","``","to_quantiles","(",")","``","for","modes","``","prediction","''","and","``","quantiles","''","trainer_kwargs","(","Dict","[","str",",","Any","]",",","optional",")",":","keyword","arguments","for","the","trainer","write_interval",":","interval","to","write","predictions","to","disk","output_dir",":","directory","to","write","predictions","to",".","Defaults","to","None",".","If","set","function","will","return","empty","list","n_samples",":","number","of","samples","to","draw",".","Defaults","to","100",".","Returns",":","Prediction",":","if","one","of","the","``","`","return","``","arguments","is","present",",","prediction","tuple","with","fields","``","prediction","``",",","``","x","``",",","``","y","``",",","``","index","``","and","``","decoder_lengths","``"]
code: def predict(
      self,
      data: Union[DataLoader, pd.DataFrame, TimeSeriesDataSet],
      mode: Union[str, Tuple[str, str]] = "prediction",
      return_index: bool = False,
      return_decoder_lengths: bool = False,
      batch_size: int = 64,
      num_workers: int = 0,
      fast_dev_run: bool = False,
      return_x: bool = False,
      return_y: bool = False,
      mode_kwargs: Dict[str, Any] = None,
      trainer_kwargs: Optional[Dict[str, Any]] = None,
      write_interval: Literal[
          "batch", "epoch", "batch_and_epoch"
      ] = "batch",
      output_dir: Optional[str] = None,
      n_samples: int = 100,
      **kwargs,
  ) -> Prediction:
      """
      predict dataloader
  
      Args:
          dataloader: dataloader, dataframe or dataset
          mode: one of "prediction", "quantiles", "samples" or "raw", or tuple ``("raw", output_name)`` where
              output_name is a name in the dictionary returned by ``forward()``
          return_index: if to return the prediction index (in the same order as the output, i.e. the row of the
              dataframe corresponds to the first dimension of the output and the given time index is the time index
              of the first prediction)
          return_decoder_lengths: if to return decoder_lengths (in the same order as the output
          batch_size: batch size for dataloader - only used if data is not a dataloader is passed
          num_workers: number of workers for dataloader - only used if data is not a dataloader is passed
          fast_dev_run: if to only return results of first batch
          show_progress_bar: if to show progress bar. Defaults to False.
          return_x: if to return network inputs (in the same order as prediction output)
          return_y: if to return network targets (in the same order as prediction output)
          mode_kwargs (Dict[str, Any]): keyword arguments for ``to_prediction()`` or ``to_quantiles()``
              for modes "prediction" and "quantiles"
          trainer_kwargs (Dict[str, Any], optional): keyword arguments for the trainer
          write_interval: interval to write predictions to disk
          output_dir: directory to write predictions to. Defaults to None. If set function will return empty list
          n_samples: number of samples to draw. Defaults to 100.
  
      Returns:
          Prediction: if one of the ```return`` arguments is present,
              prediction tuple with fields ``prediction``, ``x``, ``y``, ``index`` and ``decoder_lengths``
      """
      if isinstance(mode, str):
          if mode in ["prediction", "quantiles"]:
              if mode_kwargs is None:
                  mode_kwargs = dict(use_metric=False)
              else:
                  mode_kwargs = deepcopy(mode_kwargs)
                  mode_kwargs["use_metric"] = False
          elif mode == "samples":
              mode = ("raw", "prediction")
      return super().predict(
          data=data,
          mode=mode,
          return_decoder_lengths=return_decoder_lengths,
          return_index=return_index,
          n_samples=n_samples,  # new keyword that is passed to forward function
          return_x=return_x,
          fast_dev_run=fast_dev_run,
          num_workers=num_workers,
          batch_size=batch_size,
          mode_kwargs=mode_kwargs,
          trainer_kwargs=trainer_kwargs,
          write_interval=write_interval,
          output_dir=output_dir,
          return_y=return_y,
          **kwargs,
      )
  
imports: from copy import copy, deepcopy
  from typing import Any, Dict, List, Literal, Optional, Tuple, Union
  import numpy
  import pandas
  import torch
  import torch.nn
  from torch.utils.data.dataloader import DataLoader
  from pytorch_forecasting.data.encoders import EncoderNormalizer, MultiNormalizer, NaNLabelEncoder
  from pytorch_forecasting.data.timeseries import TimeSeriesDataSet
  from pytorch_forecasting.metrics import MAE, MAPE, MASE, RMSE, SMAPE, DistributionLoss, Metric, MultiLoss, MultivariateDistributionLoss, NormalDistributionLoss
  from pytorch_forecasting.models.base_model import AutoRegressiveBaseModelWithCovariates, Prediction
  from pytorch_forecasting.models.nn import HiddenState, MultiEmbedding, get_rnn
  from pytorch_forecasting.utils import apply_to_list, to_list
label_desc: Use image node_id 9 for calling the DeepAR obj's underlying member method code with example usage: obj.predict(data, mode, return_index, return_decoder_lengths, batch_size, num_workers, fast_dev_run, return_x, return_y, mode_kwargs, trainer_kwargs, write_interval, output_dir, n_samples) and returns: super