class_docstr: Convenience class for analyzers that revert the model's structure.
  
  This class contains many helper functions around the graph
  reverse function :func:`innvestigate.backend.graph.reverse_model`.
  
  The deriving classes should specify how the graph should be reverted
  by implementing the following functions:
  
  * :func:`_reverse_mapping(layer)` given a layer this function
    returns a reverse mapping for the layer as specified in
    :func:`innvestigate.backend.graph.reverse_model` or None.
  
    This function can be implemented, but it is encouraged to
    implement a default mapping and add additional changes with
    the function :func:`_add_conditional_reverse_mapping` (see below).
  
    The default behavior is finding a conditional mapping (see below),
    if none is found, :func:`_default_reverse_mapping` is applied.
  * :func:`_default_reverse_mapping` defines the default
    reverse mapping.
  * :func:`_head_mapping` defines how the outputs of the model
    should be instantiated before the are passed to the reversed
    network.
  
  Furthermore other parameters of the function
  :func:`innvestigate.backend.graph.reverse_model` can
  be changed by setting the according parameters of the
  init function:
  
  :param reverse_verbose: Print information on the reverse process.
  :param reverse_clip_values: Clip the values that are passed along
    the reverted network. Expects tuple (min, max).
  :param reverse_project_bottleneck_layers: Project the value range
    of bottleneck tensors in the reverse network into another range.
  :param reverse_check_min_max_values: Print the min/max values
    observed in each tensor along the reverse network whenever
    :func:`analyze` is called.
  :param reverse_check_finite: Check if values passed along the
    reverse network are finite.
  :param reverse_keep_tensors: Keeps the tensors created in the
    backward pass and stores them in the attribute
    :attr:`_reversed_tensors`.
  :param reverse_reapply_on_copied_layers: See
    :func:`innvestigate.backend.graph.reverse_model`.
docstr: Returns masked gradient.
docstr_tok: ["Returns","masked","gradient","."]
code: def _gradient_reverse_mapping(
      self,
      Xs: OptionalList[Tensor],
      Ys: OptionalList[Tensor],
      reversed_Ys: OptionalList[Tensor],
      reverse_state: dict,
  ):
      """Returns masked gradient."""
      mask = [
          id(X) not in reverse_state["stop_mapping_at_ids"] for X in Xs
      ]
      grad = ibackend.gradients(Xs, Ys, reversed_Ys)
      return ibackend.apply_mask(grad, mask)
  
imports: from __future__ import annotations
  from typing import Callable
  import numpy
  import tensorflow.keras.backend
  import innvestigate.backend
  import innvestigate.backend.graph
  import innvestigate.layers
  from innvestigate.analyzer.network_base import AnalyzerNetworkBase
  from innvestigate.backend.types import CondReverseMapping, Layer, Model, OptionalList, ReverseTensorDict, Tensor
label_desc: Use image node_id 2 for calling the ReverseAnalyzerBase obj's underlying member method code with example usage: obj._gradient_reverse_mapping(Xs, Ys, reversed_Ys, reverse_state) and returns: ibackend