docstr: Make figures that interpret model.
  
  * Attention
  * Variable selection weights / importances
  
  Args:
      interpretation: as obtained from ``interpret_output()``
  
  Returns:
      dictionary of matplotlib figures
docstr_tok: ["Make","figures","that","interpret","model",".","*","Attention","*","Variable","selection","weights","\/","importances","Args",":","interpretation",":","as","obtained","from","``","interpret_output","(",")","``","Returns",":","dictionary","of","matplotlib","figures"]
code: def plot_interpretation(
      self, interpretation: Dict[str, torch.Tensor]
  ) -> Dict[str, plt.Figure]:
      """
      Make figures that interpret model.
  
      * Attention
      * Variable selection weights / importances
  
      Args:
          interpretation: as obtained from ``interpret_output()``
  
      Returns:
          dictionary of matplotlib figures
      """
      figs = {}
  
      # attention
      fig, ax = plt.subplots()
      attention = interpretation["attention"].detach().cpu()
      attention = attention / attention.sum(-1).unsqueeze(-1)
      ax.plot(
          np.arange(
              -self.hparams.max_encoder_length,
              attention.size(0) - self.hparams.max_encoder_length,
          ),
          attention,
      )
      ax.set_xlabel("Time index")
      ax.set_ylabel("Attention")
      ax.set_title("Attention")
      figs["attention"] = fig
  
      # variable selection
      def make_selection_plot(title, values, labels):
          fig, ax = plt.subplots(figsize=(7, len(values) * 0.25 + 2))
          order = np.argsort(values)
          values = values / values.sum(-1).unsqueeze(-1)
          ax.barh(
              np.arange(len(values)),
              values[order] * 100,
              tick_label=np.asarray(labels)[order],
          )
          ax.set_title(title)
          ax.set_xlabel("Importance in %")
          plt.tight_layout()
          return fig
  
      figs["static_variables"] = make_selection_plot(
          "Static variables importance",
          interpretation["static_variables"].detach().cpu(),
          self.static_variables,
      )
      figs["encoder_variables"] = make_selection_plot(
          "Encoder variables importance",
          interpretation["encoder_variables"].detach().cpu(),
          self.encoder_variables,
      )
      figs["decoder_variables"] = make_selection_plot(
          "Decoder variables importance",
          interpretation["decoder_variables"].detach().cpu(),
          self.decoder_variables,
      )
  
      return figs
  
imports: from copy import copy
  from typing import Dict, List, Tuple, Union
  from matplotlib import pyplot
  import numpy
  import torch
  from torch import nn
  from torchmetrics import Metric
  from pytorch_forecasting.data import TimeSeriesDataSet
  from pytorch_forecasting.data.encoders import NaNLabelEncoder
  from pytorch_forecasting.metrics import MAE, MAPE, MASE, RMSE, SMAPE, MultiHorizonMetric, MultiLoss, QuantileLoss
  from pytorch_forecasting.models.base_model import BaseModelWithCovariates
  from pytorch_forecasting.models.nn import LSTM, MultiEmbedding
  from pytorch_forecasting.models.temporal_fusion_transformer.sub_modules import AddNorm, GateAddNorm, GatedLinearUnit, GatedResidualNetwork, InterpretableMultiHeadAttention, VariableSelectionNetwork
  from pytorch_forecasting.utils import create_mask, detach, integer_histogram, masked_op, padded_stack, to_list
label_desc: Use image node_id 12 for calling the TemporalFusionTransformer obj's underlying member method code with example usage: obj.plot_interpretation(interpretation) and returns: figs, fig