code: def test_rsample(self):
      # TODO: Replace with e.g. two-sample test.
      with torch.random.fork_rng():
          torch.random.manual_seed(next(self.seed_generator))
  
          # Pick a USN distribution at random
          index = torch.randint(
              low=0, high=len(self.distributions), size=()
          )
          usn = self.distributions[index]
          sqrt_covariance = self.sqrt_covariances[index]
  
          # Generate draws using `rsample`
          samples_y = usn.rsample(
              sample_shape=torch.Size([self.mc_num_rsamples])
          )
          means = samples_y.mean(0)
          covar = samples_y.T.cov()
  
          # Generate draws using rejection sampling
          ndim = sqrt_covariance.shape[-1]
          base_rvs = torch.randn(
              self.mc_num_samples, ndim, **self.tkwargs
          )
          _samples_x, _samples_y = (base_rvs @ sqrt_covariance.T).split(
              usn.trunc.event_shape + usn.gauss.event_shape, dim=-1
          )
  
          _accept = torch.logical_and(
              (
                  _samples_x > usn.trunc.bounds[..., 0] - usn.trunc.loc
              ).all(-1),
              (
                  _samples_x < usn.trunc.bounds[..., 1] - usn.trunc.loc
              ).all(-1),
          )
  
          _means = usn.gauss.loc + _samples_y[_accept].mean(0)
          _covar = _samples_y[_accept].T.cov()
  
          atol = self.mc_atol_multiplier * (
              _accept.count_nonzero() ** -0.5
              + self.mc_num_rsamples**-0.5
          )
  
          self.assertAllClose(_means, means, rtol=0, atol=atol)
          self.assertAllClose(_covar, covar, rtol=0, atol=atol)
  
imports: from __future__ import annotations
  from copy import deepcopy
  from itertools import count
  from typing import Any, Dict, Optional, Sequence, Tuple
  import torch
  from botorch.utils.probability.mvnxpb import MVNXPB
  from botorch.utils.probability.truncated_multivariate_normal import TruncatedMultivariateNormal
  from botorch.utils.probability.unified_skew_normal import UnifiedSkewNormal
  from botorch.utils.testing import BotorchTestCase
  from linear_operator.operators import DenseLinearOperator
  from torch import Tensor
  from torch.distributions import MultivariateNormal
  from torch.special import ndtri
label_desc: Use image node_id 5 for calling the TestUnifiedSkewNormal obj's underlying member method code with example usage: obj.test_rsample() without return types