class_docstr: Beta distribution loss for unit interval data.
  
  Requirements for original target normalizer:
      * logit transformation
class_docstr_tok: ["Beta","distribution","loss","for","unit","interval","data",".","Requirements","for","original","target","normalizer",":","*","logit","transformation"]
code: def rescale_parameters(
      self,
      parameters: torch.Tensor,
      target_scale: torch.Tensor,
      encoder: BaseEstimator,
  ) -> torch.Tensor:
      assert encoder.transformation in [
          "logit"
      ], "Beta distribution is only compatible with logit transformation"
      assert (
          encoder.center
      ), "Beta distribution requires normalizer to center data"
  
      scaled_mean = encoder(
          dict(prediction=parameters[..., 0], target_scale=target_scale)
      )
      # need to first transform target scale standard deviation in logit space to real space
      # we assume a normal distribution in logit space (we used a logit transform and a standard scaler)
      # and know that the variance of the beta distribution is limited by `scaled_mean * (1 - scaled_mean)`
      scaled_mean = (
          scaled_mean * (1 - 2 * self.eps) + self.eps
      )  # ensure that mean is not exactly 0 or 1
      mean_derivative = scaled_mean * (1 - scaled_mean)
  
      # we can approximate variance as
      # torch.pow(torch.tanh(target_scale[..., 1].unsqueeze(1) * torch.sqrt(mean_derivative)), 2) * mean_derivative
      # shape is (positive) parameter * mean_derivative / var
      shape_scaler = (
          torch.pow(
              torch.tanh(
                  target_scale[..., 1].unsqueeze(1)
                  * torch.sqrt(mean_derivative)
              ),
              2,
          )
          + self.eps
      )
      scaled_shape = F.softplus(parameters[..., 1]) / shape_scaler
      return torch.stack([scaled_mean, scaled_shape], dim=-1)
  
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 BetaDistributionLoss obj's underlying member method code with example usage: obj.rescale_parameters(parameters, target_scale, encoder) and returns: torch