docstr: Plot interpretation.
  
  Plot two pannels: prediction and backcast vs actuals and
  decomposition of prediction into trend, seasonality and generic forecast.
  
  Args:
      x (Dict[str, torch.Tensor]): network input
      output (Dict[str, torch.Tensor]): network output
      idx (int): index of sample for which to plot the interpretation.
      ax (List[matplotlib axes], optional): list of two matplotlib axes onto which to plot the interpretation.
          Defaults to None.
      plot_seasonality_and_generic_on_secondary_axis (bool, optional): if to plot seasonality and
          generic forecast on secondary axis in second panel. Defaults to False.
  
  Returns:
      plt.Figure: matplotlib figure
docstr_tok: ["Plot","interpretation",".","Plot","two","pannels",":","prediction","and","backcast","vs","actuals","and","decomposition","of","prediction","into","trend",",","seasonality","and","generic","forecast",".","Args",":","x","(","Dict","[","str",",","torch.Tensor","]",")",":","network","input","output","(","Dict","[","str",",","torch.Tensor","]",")",":","network","output","idx","(","int",")",":","index","of","sample","for","which","to","plot","the","interpretation",".","ax","(","List","[","matplotlib","axes","]",",","optional",")",":","list","of","two","matplotlib","axes","onto","which","to","plot","the","interpretation",".","Defaults","to","None",".","plot_seasonality_and_generic_on_secondary_axis","(","bool",",","optional",")",":","if","to","plot","seasonality","and","generic","forecast","on","secondary","axis","in","second","panel",".","Defaults","to","False",".","Returns",":","plt.Figure",":","matplotlib","figure"]
code: def plot_interpretation(
      self,
      x: Dict[str, torch.Tensor],
      output: Dict[str, torch.Tensor],
      idx: int,
      ax=None,
      plot_seasonality_and_generic_on_secondary_axis: bool = False,
  ) -> plt.Figure:
      """
      Plot interpretation.
  
      Plot two pannels: prediction and backcast vs actuals and
      decomposition of prediction into trend, seasonality and generic forecast.
  
      Args:
          x (Dict[str, torch.Tensor]): network input
          output (Dict[str, torch.Tensor]): network output
          idx (int): index of sample for which to plot the interpretation.
          ax (List[matplotlib axes], optional): list of two matplotlib axes onto which to plot the interpretation.
              Defaults to None.
          plot_seasonality_and_generic_on_secondary_axis (bool, optional): if to plot seasonality and
              generic forecast on secondary axis in second panel. Defaults to False.
  
      Returns:
          plt.Figure: matplotlib figure
      """
      if ax is None:
          fig, ax = plt.subplots(2, 1, figsize=(6, 8))
      else:
          fig = ax[0].get_figure()
  
      time = torch.arange(
          -self.hparams.context_length, self.hparams.prediction_length
      )
  
      # plot target vs prediction
      ax[0].plot(
          time,
          torch.cat(
              [x["encoder_target"][idx], x["decoder_target"][idx]]
          )
          .detach()
          .cpu(),
          label="target",
      )
      ax[0].plot(
          time,
          torch.cat(
              [
                  output["backcast"][idx].detach(),
                  output["prediction"][idx].detach(),
              ],
              dim=0,
          ).cpu(),
          label="prediction",
      )
      ax[0].set_xlabel("Time")
  
      # plot blocks
      prop_cycle = iter(plt.rcParams["axes.prop_cycle"])
      next(prop_cycle)  # prediction
      next(prop_cycle)  # observations
      if plot_seasonality_and_generic_on_secondary_axis:
          ax2 = ax[1].twinx()
          ax2.set_ylabel("Seasonality / Generic")
      else:
          ax2 = ax[1]
      for title in ["trend", "seasonality", "generic"]:
          if title not in self.hparams.stack_types:
              continue
          if title == "trend":
              ax[1].plot(
                  time,
                  output[title][idx].detach().cpu(),
                  label=title.capitalize(),
                  c=next(prop_cycle)["color"],
              )
          else:
              ax2.plot(
                  time,
                  output[title][idx].detach().cpu(),
                  label=title.capitalize(),
                  c=next(prop_cycle)["color"],
              )
      ax[1].set_xlabel("Time")
      ax[1].set_ylabel("Decomposition")
  
      fig.legend()
      return fig
  
file_path: pytorch-forecasting/pytorch_forecasting/models/nbeats/__init__.py
imports: from typing import Dict, List
  import matplotlib.pyplot
  import torch
  from torch import nn
  from pytorch_forecasting.data import TimeSeriesDataSet
  from pytorch_forecasting.data.encoders import NaNLabelEncoder
  from pytorch_forecasting.metrics import MAE, MAPE, MASE, RMSE, SMAPE, MultiHorizonMetric
  from pytorch_forecasting.models.base_model import BaseModel
  from pytorch_forecasting.models.nbeats.sub_modules import NBEATSGenericBlock, NBEATSSeasonalBlock, NBEATSTrendBlock
label_desc: Use image node_id 6 for calling the NBeats obj's underlying member method code with example usage: obj.plot_interpretation(x, output, idx, ax, plot_seasonality_and_generic_on_secondary_axis) and returns: fig