docstr: Updates the explainer state (see :py:meth:`alibi.explainers.anchors.anchor_base.AnchorBaseBeam.__init__`
  for full state definition).
  
  Parameters
  ----------
  covered_true
      Examples where the result applies and the prediction is the same as on
      the instance to be explained.
  covered_false
      Examples where the result applies and the prediction is the different to
      the instance to be explained.
  samples
      A tuple containing discretized data, coverage and the result sampled.
  labels
      An array indicating whether the prediction on the sample matches the label
      of the instance to be explained.
  anchor
      The result to be updated.
  
  Returns
  -------
  A tuple containing the number of instances equals desired label of observation         to be explained the total number of instances sampled, and the result that was sampled.
docstr_tok: ["Updates","the","explainer","state","(","see",":","py",":","meth",":","`","alibi.explainers.anchors.anchor_base.AnchorBaseBeam.__init__","`","for","full","state","definition",")",".","Parameters","--","--","--","--","--","covered_true","Examples","where","the","result","applies","and","the","prediction","is","the","same","as","on","the","instance","to","be","explained",".","covered_false","Examples","where","the","result","applies","and","the","prediction","is","the","different","to","the","instance","to","be","explained",".","samples","A","tuple","containing","discretized","data",",","coverage","and","the","result","sampled",".","labels","An","array","indicating","whether","the","prediction","on","the","sample","matches","the","label","of","the","instance","to","be","explained",".","anchor","The","result","to","be","updated",".","Returns","--","--","--","-","A","tuple","containing","the","number","of","instances","equals","desired","label","of","observation","to","be","explained","the","total","number","of","instances","sampled",",","and","the","result","that","was","sampled","."]
code: def update_state(
      self,
      covered_true: np.ndarray,
      covered_false: np.ndarray,
      labels: np.ndarray,
      samples: Tuple[np.ndarray, float],
      anchor: tuple,
  ) -> Tuple[int, int]:
      """
          Updates the explainer state (see :py:meth:`alibi.explainers.anchors.anchor_base.AnchorBaseBeam.__init__`
          for full state definition).
  
          Parameters
          ----------
          covered_true
              Examples where the result applies and the prediction is the same as on
              the instance to be explained.
          covered_false
              Examples where the result applies and the prediction is the different to
              the instance to be explained.
          samples
              A tuple containing discretized data, coverage and the result sampled.
          labels
              An array indicating whether the prediction on the sample matches the label
              of the instance to be explained.
          anchor
              The result to be updated.
  
          Returns
          -------
          A tuple containing the number of instances equals desired label of observation \
          to be explained the total number of instances sampled, and the result that was sampled.
          """
  
      # data = binary matrix where 1 means a feature has the same value as the feature in the result
      data, coverage = samples
      n_samples = data.shape[0]
  
      current_idx = self.state["current_idx"]
      idxs = range(current_idx, current_idx + n_samples)
      self.state["t_idx"][anchor].update(idxs)
      self.state["t_nsamples"][anchor] += n_samples
      self.state["t_positives"][anchor] += labels.sum()
      self.state["t_covered_true"][anchor] = covered_true
      self.state["t_covered_false"][anchor] = covered_false
      self.state["data"][idxs] = data
      self.state["labels"][idxs] = labels
      self.state["current_idx"] += n_samples
  
      if self.state["current_idx"] >= self.state["data"].shape[0] - max(
          self.margin, n_samples
      ):
          prealloc_size = self.state["prealloc_size"]
          self.state["data"] = np.vstack(
              (
                  self.state["data"],
                  np.zeros((prealloc_size, data.shape[1]), data.dtype),
              )
          )
          self.state["labels"] = np.hstack(
              (
                  self.state["labels"],
                  np.zeros(prealloc_size, labels.dtype),
              )
          )
  
      return labels.sum(), data.shape[0]
  
imports: import copy
  import logging
  from collections import defaultdict, namedtuple
  from typing import Callable, Dict, List, Optional, Set, Tuple
  import numpy
  from alibi.utils.distributions import kl_bernoulli
label_desc: Use image node_id 12 for calling the AnchorBaseBeam obj's underlying member method code with example usage: obj.update_state(covered_true, covered_false, labels, samples, anchor) and returns: labels,  data