code: def _bisect_lambda(self, cf_found, l_step, lam, lam_lb, lam_ub):
      for batch_idx in range(
          self.batch_size
      ):  # TODO: batch not supported
          if (
              cf_found[batch_idx][l_step] >= 5
          ):  # minimum number of CF instances to warrant increasing lambda
              # want to improve the solution by putting more weight on the distance term TODO: hyperparameter?
              # by increasing lambda
              lam_lb[batch_idx] = max(lam[batch_idx], lam_lb[batch_idx])
              logger.debug(
                  "Lambda bounds: (%s, %s)",
                  lam_lb[batch_idx],
                  lam_ub[batch_idx],
              )
              if lam_ub[batch_idx] < 1e9:
                  lam[batch_idx] = (
                      lam_lb[batch_idx] + lam_ub[batch_idx]
                  ) / 2
              else:
                  lam[batch_idx] *= 10
                  logger.debug("Changed lambda to %s", lam[batch_idx])
  
          elif cf_found[batch_idx][l_step] < 5:
              # if not enough solutions found so far, decrease lambda by a factor of 10,
              # otherwise bisect up to the last known successful lambda
              lam_ub[batch_idx] = min(lam_ub[batch_idx], lam[batch_idx])
              logger.debug(
                  "Lambda bounds: (%s, %s)",
                  lam_lb[batch_idx],
                  lam_ub[batch_idx],
              )
              if lam_lb[batch_idx] > 0:
                  lam[batch_idx] = (
                      lam_lb[batch_idx] + lam_ub[batch_idx]
                  ) / 2
                  logger.debug("Changed lambda to %s", lam[batch_idx])
              else:
                  lam[batch_idx] /= 10
  
      return lam, lam_lb, lam_ub
  
imports: import copy
  import logging
  from typing import Callable, Optional, Tuple, Union
  import numpy
  import tensorflow.compat.v1
  from alibi.api.defaults import DEFAULT_DATA_CF, DEFAULT_META_CF
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.utils.gradients import num_grad_batch
label_desc: Use image node_id 8 for calling the Counterfactual obj's underlying member method code with example usage: obj._bisect_lambda(cf_found, l_step, lam, lam_lb, lam_ub) and returns: lam,  lam_lb,  lam_ub