code: def _density_sample(self, loglstar):
      self.trainer.netG.eval()
  
      ncall = 0
      while True:
          z = self.trainer.get_prior_samples(1)
          try:
              x = self.trainer.get_samples(z, to_numpy=True)
          except:
              continue
  
          if self.prior(x) < -1e30:
              continue
  
          logl, derived = self.loglike(x)
          ncall += 1
          if logl[0] > loglstar:
              break
  
      return x, logl, derived, ncall
  
imports: from __future__ import print_function
  from __future__ import division
  import os
  import json
  import logging
  import time
  import torch
  import numpy
  from tqdm import tqdm
  import matplotlib.pyplot
  from nnest.trainer import Trainer
  from nnest.utils.evaluation import acceptance_rate, effective_sample_size, mean_jump_distance, gelman_rubin_diagnostic
  from nnest.utils.logger import create_logger, get_or_create_run_dir
label_desc: Use image node_id 9 for calling the Sampler obj's underlying member method code with example usage: obj._density_sample(loglstar) and returns: x,  logl,  derived,  ncall