class_docstr: The ``PyTorchForecastingAdapter`` is an :class:`~flash.core.adapter.Adapter` for integrating with PyTorch
  Forecasting.
class_docstr_tok: ["The","``","PyTorchForecastingAdapter","``","is","an",":","class",":","`","~flash.core.adapter.Adapter","`","for","integrating","with","PyTorch","Forecasting","."]
code: def from_task(
      cls,
      task: Task,
      parameters: Dict[str, Any],
      backbone: str,
      backbone_kwargs: Optional[Dict[str, Any]] = None,
      loss_fn: Optional[Callable] = None,
      metrics: Optional[
          Union[torchmetrics.Metric, List[torchmetrics.Metric]]
      ] = None,
  ) -> Adapter:
      parameters = copy(parameters)
      # Remove the single row of data from the parameters to reconstruct the `time_series_dataset`
      data = DataFrame.from_dict(parameters.pop("data_sample"))
      time_series_dataset = PatchTimeSeriesDataSet.from_parameters(
          parameters, data
      )
  
      backbone_kwargs["loss"] = loss_fn
  
      if metrics is not None and not isinstance(metrics, list):
          metrics = [metrics]
      backbone_kwargs["logging_metrics"] = metrics
  
      backbone_kwargs = backbone_kwargs or {}
  
      adapter = cls(
          task.backbones.get(backbone)(
              time_series_dataset=time_series_dataset, **backbone_kwargs
          )
      )
  
      # Attach the required collate function
      adapter.collate_fn = partial(
          PyTorchForecastingAdapter._collate_fn,
          time_series_dataset._collate_fn,
      )
  
      return adapter
  
imports: from copy import copy
  from functools import partial
  from typing import Any, Callable, Dict, List, Optional, Union
  import torchmetrics
  from torch import Tensor
  from flash.core.adapter import Adapter
  from flash.core.data.batch import default_uncollate
  from flash.core.data.io.input import DataKeys
  from flash.core.model import Task
  from flash.core.utilities.imports import _FORECASTING_AVAILABLE, _PANDAS_AVAILABLE
label_desc: Use image node_id 3 for calling the PyTorchForecastingAdapter obj's underlying member method code with example usage: obj.from_task(cls, task, parameters, backbone, backbone_kwargs, loss_fn, metrics) and returns: adapter