class_docstr: Implicit Quantile Network Distribution Loss.
  
  Based on `Probabilistic Time Series Forecasting with Implicit Quantile Networks
  <https://arxiv.org/pdf/2107.03743.pdf>`_.
  A network is used to directly map network outputs to a quantile.
class_docstr_tok: ["Implicit","Quantile","Network","Distribution","Loss",".","Based","on","`","Probabilistic","Time","Series","Forecasting","with","Implicit","Quantile","Networks","<","https",":","\/\/arxiv.org\/pdf\/2107.03743.pdf",">","`","_",".","A","network","is","used","to","directly","map","network","outputs","to","a","quantile","."]
docstr: Calculate negative likelihood
  
  Args:
      y_pred: network output
      y_actual: actual values
  
  Returns:
      torch.Tensor: metric value on which backpropagation can be applied
docstr_tok: ["Calculate","negative","likelihood","Args",":","y_pred",":","network","output","y_actual",":","actual","values","Returns",":","torch.Tensor",":","metric","value","on","which","backpropagation","can","be","applied"]
code: def loss(
      self, y_pred: torch.Tensor, y_actual: torch.Tensor
  ) -> torch.Tensor:
      """
      Calculate negative likelihood
  
      Args:
          y_pred: network output
          y_actual: actual values
  
      Returns:
          torch.Tensor: metric value on which backpropagation can be applied
      """
      eps = 1e-3
      # for a couple of random quantiles (excl. 0 and 1 as they would lead to infinities)
      quantiles = torch.rand(
          size=(self.n_loss_samples,), device=y_pred.device
      ).clamp(eps, 1 - eps)
      # make prediction
      pred_quantiles = self.to_quantiles(y_pred, quantiles=quantiles)
      # and calculate quantile loss
      errors = y_actual[..., None] - pred_quantiles
      loss = 2 * torch.fmax(
          quantiles[None] * errors, (quantiles[None] - 1) * errors
      ).mean(dim=-1)
      return loss
  
imports: from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  from sklearn.base import BaseEstimator
  import torch
  from torch import distributions, nn
  import torch.nn.functional
  from pytorch_forecasting.data.encoders import TorchNormalizer, softplus_inv
  from pytorch_forecasting.metrics.base_metrics import DistributionLoss, MultivariateDistributionLoss
label_desc: Use image node_id 3 for calling the ImplicitQuantileNetworkDistributionLoss obj's underlying member method code with example usage: obj.loss(y_pred, y_actual) and returns: loss