code: def test_splicedbinnedpareto_likelihood(
      percentile_tail: PositiveFloat,
      np_logits: np.ndarray,
      lower_gp_xi: float,
      lower_gp_beta: PositiveFloat,
      upper_gp_xi: float,
      upper_gp_beta: PositiveFloat,
  ) -> None:
      # percentile_tail = 0.05
      bins_lower_bound, bins_upper_bound = -1.0, 2.0
      # np_logits = [percentile_tail, 1 - 2 * percentile_tail, percentile_tail]
      # upper_gp_xi, upper_gp_beta = 0.3, 1
      # lower_gp_xi, lower_gp_beta = 0.4, 1
  
      assert (
          percentile_tail < 1
      ), "percentile_tail should be between 0.0 and 1.0"
  
      # Specify the distribution with parameter value from which to obtain samples
      NUM_SAMPLES = 10_000
  
      logits = torch.tensor(np_logits).unsqueeze(0)
      logits = logits.repeat(NUM_SAMPLES, 1)
      nbins = logits.shape[-1]
      distr_true = SplicedBinnedPareto(
          bins_lower_bound=bins_lower_bound,
          bins_upper_bound=bins_upper_bound,
          tail_percentile_gen_pareto=percentile_tail,
          numb_bins=nbins,
          logits=logits,
          lower_gp_xi=torch.tensor(
              lower_gp_xi, dtype=torch.float
          ).repeat(NUM_SAMPLES, 1),
          lower_gp_beta=torch.tensor(
              lower_gp_beta, dtype=torch.float
          ).repeat(NUM_SAMPLES, 1),
          upper_gp_xi=torch.tensor(
              upper_gp_xi, dtype=torch.float
          ).repeat(NUM_SAMPLES, 1),
          upper_gp_beta=torch.tensor(
              upper_gp_beta, dtype=torch.float
          ).repeat(NUM_SAMPLES, 1),
      )
      samples = distr_true.sample()
  
      # DistributionOutput
      distr_output = SplicedBinnedParetoOutput(
          bins_lower_bound=bins_lower_bound,
          bins_upper_bound=bins_upper_bound,
          num_bins=nbins,
          tail_percentile_gen_pareto=percentile_tail,
      )
  
      params_hat_values = maximum_likelihood_estimate_sgd(
          distr_output,
          samples,
          num_epochs=50,
      )
  
      params_hat = dict(
          zip(list(distr_output.args_dim.keys()), params_hat_values)
      )
  
      for param_name in params_hat.keys():
          param_hat = params_hat[param_name]
          param_true = (
              torch.unique(
                  distr_true.__getattribute__(param_name), dim=0
              )
              .detach()
              .numpy()
          )
  
          if param_name == "logits":
              compare_logits(param_true, param_hat, TOL=TOL)
          else:
              assert (
                  np.abs(param_hat - param_true) < TOL * param_true
              ).all(), f"{param_name} did not match: {param_name} = {param_true}, {param_name}_hat = {param_hat}"
  
imports: from typing import List
  import numpy
  import pytest
  import torch
  import torch.nn
  from scipy.special import softmax
  from torch.distributions import Beta, Gamma, NegativeBinomial, Normal, Poisson, StudentT
  from torch.nn.utils import clip_grad_norm_
  from torch.optim import SGD
  from torch.utils.data import DataLoader, TensorDataset
  from gluonts.pydantic import PositiveFloat, PositiveInt
  from gluonts.torch.distributions import BetaOutput, DistributionOutput, GammaOutput, NegativeBinomialOutput, NormalOutput, PoissonOutput, SplicedBinnedPareto, SplicedBinnedParetoOutput, StudentTOutput
label_desc: Use image node_id 11 for calling a global function with example usage: test_splicedbinnedpareto_likelihood(percentile_tail, np_logits, lower_gp_xi, lower_gp_beta, upper_gp_xi, upper_gp_beta) without return types