class_docstr: The ZPlus rule is a special case of the AlphaBetaRule
  for alpha=1, beta=0 and assumes inputs x >= 0.
class_docstr_tok: ["The","ZPlus","rule","is","a","special","case","of","the","AlphaBetaRule","for","alpha=1",",","beta=0","and","assumes","inputs","x",">","=","0","."]
code: def __init__(self, layer: Layer, _state, copy_weights=False):
      # The z-plus rule only works with positive weights and
      # no biases.
      # TODO: assert that layer inputs are always >= 0
      if copy_weights:
          weights = layer.get_weights()
          if getattr(layer, "use_bias", False):
              weights = weights[:-1]
          weights = [x * (x > 0) for x in weights]
      else:
          weights = layer.weights
          if getattr(layer, "use_bias", False):
              weights = weights[:-1]
          weights = [
              x * ibackend.cast_to_floatx(x > 0) for x in weights
          ]
  
      self._layer_wo_act_b_positive = igraph.copy_layer_wo_activation(
          layer,
          keep_bias=False,
          weights=weights,
          name_template="reversed_kernel_positive_%s",
      )
  
imports: from __future__ import annotations
  import numpy
  import tensorflow.keras.backend
  import tensorflow.keras.layers
  import innvestigate.analyzer.relevance_based.utils
  import innvestigate.backend
  import innvestigate.backend.graph
  import innvestigate.layers
  from innvestigate.backend.types import Layer, OptionalList, Tensor
label_desc: Use image node_id 1 to create a new ZPlusFastRule object from inherited base classes: igraph with example: obj = ZPlusFastRule(layer, _state, copy_weights)