code: def lucb(
      sample_fns,
      initial_stats,
      epsilon,
      delta,
      batch_size,
      top_n,
      verbose=False,
      verbose_every=1,
  ):
      # initial_stats must have n_samples, positive
      n_features = len(sample_fns)
      n_samples = np.array(initial_stats["n_samples"])
      positives = np.array(initial_stats["positives"])
      ub = np.zeros(n_samples.shape)
      lb = np.zeros(n_samples.shape)
      for f in np.where(n_samples == 0)[0]:
          n_samples[f] += 1
          positives[f] += sample_fns[f](1)
      if n_features == top_n:
          return range(n_features)
      means = positives / n_samples
      t = 1
  
      def update_bounds(t):
          sorted_means = np.argsort(means)
          beta = AnchorBaseBeam.compute_beta(n_features, t, delta)
          J = sorted_means[-top_n:]
          not_J = sorted_means[:-top_n]
          for f in not_J:
              ub[f] = AnchorBaseBeam.dup_bernoulli(
                  means[f], beta / n_samples[f]
              )
          for f in J:
              lb[f] = AnchorBaseBeam.dlow_bernoulli(
                  means[f], beta / n_samples[f]
              )
          ut = not_J[np.argmax(ub[not_J])]
          lt = J[np.argmin(lb[J])]
          return ut, lt
  
      ut, lt = update_bounds(t)
      B = ub[ut] - lb[lt]
      verbose_count = 0
      while B > epsilon:
          verbose_count += 1
          if verbose and verbose_count % verbose_every == 0:
              print(
                  "Best: %d (mean:%.10f, n: %d, lb:%.4f)"
                  % (lt, means[lt], n_samples[lt], lb[lt]),
                  end=" ",
              )
              print(
                  "Worst: %d (mean:%.4f, n: %d, ub:%.4f)"
                  % (ut, means[ut], n_samples[ut], ub[ut]),
                  end=" ",
              )
              print("B = %.2f" % B)
          n_samples[ut] += batch_size
          positives[ut] += sample_fns[ut](batch_size)
          means[ut] = positives[ut] / n_samples[ut]
          n_samples[lt] += batch_size
          positives[lt] += sample_fns[lt](batch_size)
          means[lt] = positives[lt] / n_samples[lt]
          t += 1
          ut, lt = update_bounds(t)
          B = ub[ut] - lb[lt]
      sorted_means = np.argsort(means)
      return sorted_means[-top_n:]
  
file_path: anchor/anchor/anchor_base.py
imports: from __future__ import print_function
  import numpy
  import operator
  import copy
  import sklearn
  import collections
label_desc: Use image node_id 6 for calling the AnchorBaseBeam obj's underlying member method code with example usage: obj.lucb(sample_fns, initial_stats, epsilon, delta, batch_size, top_n, verbose, verbose_every) and returns: sorted_means, range, ut,  lt