class_docstr: Tweedie loss.
  
  Tweedie regression with log-link. It might be useful, e.g., for modeling total
  loss in insurance, or for any target that might be tweedie-distributed.
  
  The loss will take the exponential of the network output before it is returned as prediction.
  Target normalizer should therefore have no "reverse" transformation, e.g.
  for the :py:class:`~data.timeseries.TimeSeriesDataSet` initialization, one could use:
  
  .. code-block:: python
  
      from pytorch_forecasting import TimeSeriesDataSet, EncoderNormalizer
  
      dataset = TimeSeriesDataSet(
          target_normalizer=EncoderNormalizer(transformation=dict(forward=torch.log1p))
      )
  
  Note that in this example, the data is log1p-transformed before normalized but not re-transformed.
  The TweedieLoss applies this "exp"-re-transformation on the network output after it has been de-normalized.
  The result is the model prediction.
class_docstr_tok: ["Tweedie","loss",".","Tweedie","regression","with","log-link",".","It","might","be","useful",",","e.g.",",","for","modeling","total","loss","in","insurance",",","or","for","any","target","that","might","be","tweedie-distributed",".","The","loss","will","take","the","exponential","of","the","network","output","before","it","is","returned","as","prediction",".","Target","normalizer","should","therefore","have","no","``","reverse","''","transformation",",","e.g",".","for","the",":","py",":","class",":","`","~data.timeseries.TimeSeriesDataSet","`","initialization",",","one","could","use",":","..","code-block",":",":","python","from","pytorch_forecasting","import","TimeSeriesDataSet",",","EncoderNormalizer","dataset","=","TimeSeriesDataSet","(","target_normalizer=EncoderNormalizer","(","transformation=dict","(","forward=torch.log1p",")",")",")","Note","that","in","this","example",",","the","data","is","log1p-transformed","before","normalized","but","not","re-transformed",".","The","TweedieLoss","applies","this","``","exp","''","-re-transformation","on","the","network","output","after","it","has","been","de-normalized",".","The","result","is","the","model","prediction","."]
docstr: Args:
      p (float, optional): tweedie variance power which is greater equal
          1.0 and smaller 2.0. Close to ``2`` shifts to
          Gamma distribution and close to ``1`` shifts to Poisson distribution.
          Defaults to 1.5.
      reduction (str, optional): How to reduce the loss. Defaults to "mean".
docstr_tok: ["Args",":","p","(","float",",","optional",")",":","tweedie","variance","power","which","is","greater","equal","1.0","and","smaller","2.0",".","Close","to","``","2","``","shifts","to","Gamma","distribution","and","close","to","``","1","``","shifts","to","Poisson","distribution",".","Defaults","to","1.5.","reduction","(","str",",","optional",")",":","How","to","reduce","the","loss",".","Defaults","to","``","mean","''","."]
code: def __init__(self, reduction="mean", p: float = 1.5, **kwargs):
      """
      Args:
          p (float, optional): tweedie variance power which is greater equal
              1.0 and smaller 2.0. Close to ``2`` shifts to
              Gamma distribution and close to ``1`` shifts to Poisson distribution.
              Defaults to 1.5.
          reduction (str, optional): How to reduce the loss. Defaults to "mean".
      """
      super().__init__(reduction=reduction, **kwargs)
      assert 1 <= p < 2, "p must be in range [1, 2]"
      self.p = p
  
imports: from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import scipy.stats
  import torch
  import torch.nn.functional
  from torch.nn.utils import rnn
  from pytorch_forecasting.metrics.base_metrics import MultiHorizonMetric
  from pytorch_forecasting.utils import create_mask, unpack_sequence, unsqueeze_like
label_desc: Use image node_id 1 to create a new TweedieLoss object from inherited base classes: MultiHorizonMetric with example: obj = TweedieLoss(reduction, p)