class_docstr: Multivariate quantile loss based on the article
  `Multivariate Quantile Function Forecaster <http://arxiv.org/abs/2202.11316>`_.
  
  Requires install of additional library:
  ``pip install pytorch-forecasting[mqf2]``
class_docstr_tok: ["Multivariate","quantile","loss","based","on","the","article","`","Multivariate","Quantile","Function","Forecaster","<","http",":","\/\/arxiv.org\/abs\/2202.11316",">","`","_",".","Requires","install","of","additional","library",":","``","pip","install","pytorch-forecasting","[","mqf2","]","``"]
docstr: Convert network prediction into a quantile prediction.
  
  Args:
      y_pred: prediction output of network
      quantiles (List[float], optional): quantiles for probability range. Defaults to quantiles as
          as defined in the class initialization.
  
  Returns:
      torch.Tensor: prediction quantiles (last dimension)
docstr_tok: ["Convert","network","prediction","into","a","quantile","prediction",".","Args",":","y_pred",":","prediction","output","of","network","quantiles","(","List","[","float","]",",","optional",")",":","quantiles","for","probability","range",".","Defaults","to","quantiles","as","as","defined","in","the","class","initialization",".","Returns",":","torch.Tensor",":","prediction","quantiles","(","last","dimension",")"]
code: def to_quantiles(
      self, y_pred: torch.Tensor, quantiles: List[float] = None
  ) -> torch.Tensor:
      """
      Convert network prediction into a quantile prediction.
  
      Args:
          y_pred: prediction output of network
          quantiles (List[float], optional): quantiles for probability range. Defaults to quantiles as
              as defined in the class initialization.
  
      Returns:
          torch.Tensor: prediction quantiles (last dimension)
      """
      if quantiles is None:
          quantiles = self.quantiles
      distribution = self.map_x_to_distribution(y_pred)
      alpha = (
          torch.as_tensor(quantiles, device=y_pred.device)[:, None]
          .repeat(y_pred.size(0), 1)
          .expand(-1, self.prediction_length)
      )
      hidden_state = (
          distribution.base_dist.hidden_state.repeat_interleave(
              len(quantiles), dim=0
          )
      )
      result = distribution.quantile(
          alpha, hidden_state=hidden_state
      )  # (batch_size * quantiles x prediction_length)
  
      # reshape
      result = result.reshape(
          -1, len(quantiles), self.prediction_length
      ).transpose(
          1, 2
      )  # (batch_size, prediction_length, quantile_size)
  
      return result
  
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 6 for calling the MQF2DistributionLoss obj's underlying member method code with example usage: obj.to_quantiles(y_pred, quantiles) and returns: result