code: def interprete_model(
      target_model: pl.LightningModule,
      net: str,
      forward_func: str,
      _input: torch.Tensor = None,
  ):
      """
      Returns model input attributions for a given network and forward function.
  
      Parameters
      ----------
          target_model : pl.LightningModule
              The model for which input attributions are to be computed.
  
          net : str
              Name of the network for which input attributions are to be computed.
  
          forward_func : str
              Name of the forward function for which input attributions are to be computed.
  
          _input : torch.Tensor
              Input for which the attributions are to be computed.
  
      Returns
      -------
          torch.Tensor
              Input attributions for the given network and forward function.
      """
      # Load the respective forward function from the model and init model interpreter
      forward = getattr(target_model, forward_func)
      saliency = Saliency(forward_func=forward)
  
      # Number of quantiles
      num_quantiles = len(target_model.quantiles)
      # Number of input features to the net (aka n_lags)
      num_in_features = getattr(target_model, net)[0].in_features
      # Number of output features from the net (aka n_forecasts)
      num_out_features = getattr(target_model, net)[-1].out_features
      num_out_features_without_quantiles = int(
          num_out_features / num_quantiles
      )
  
      # Create a tensor of ones as model input
      model_input = (
          torch.ones(1, num_in_features, requires_grad=True)
          if _input is None
          else _input
      )
  
      # Iterate through each output feature and compute the model attribution wrt. the input
      attributions = torch.empty((0, num_in_features))
      for output_feature in range(num_out_features_without_quantiles):
          for quantile in range(num_quantiles):
              target_attribution = saliency.attribute(
                  model_input,
                  target=[(output_feature, quantile)],
                  abs=False,
              )
              attributions = torch.cat(
                  (attributions, target_attribution), 0
              )
  
      # Average the attributions over the input features
      # Idea: Average attribution of each lag on all forecasts (eg the n'th lag has an attribution of xyz on the forecast)
      # TODO: support the visualization of 2d tensors in plot_parameters
      # (aka the attribution of the n'th lag on the m'th forecast)
  
      return attributions
  
file_path: neural_prophet/neuralprophet/utils_torch.py
imports: import inspect
  import logging
  import numpy
  import pytorch_lightning
  import torch
  import torch.nn
  from captum.attr import Saliency
label_desc: Use image node_id 4 for calling a global function with example usage: interprete_model(target_model, net, forward_func, _input) and returns: attributions