class_docstr: Convenience interface for analyzers.
  
  This class provides helpful functionality to create analyzer's.
  Basically it:
  
  * takes the input model and adds a layer that selects
    the desired output neuron to analyze.
  * passes the new model to :func:`_create_analysis` which should
    return the analysis as Keras tensors.
  * compiles the function and serves the output to :func:`analyze` calls.
  * allows :func:`_create_analysis` to return tensors
    that are intercept for debugging purposes.
  
  :param allow_lambda_layers: Allow the model to contain lambda layers.
docstr: Prepares the model to analyze before it gets actually analyzed.
  
  This class adds the code to select a specific output neuron.
docstr_tok: ["Prepares","the","model","to","analyze","before","it","gets","actually","analyzed",".","This","class","adds","the","code","to","select","a","specific","output","neuron","."]
code: def _prepare_model(
      self, model: Model
  ) -> tuple[Model, list[Tensor], list[Tensor]]:
      """
      Prepares the model to analyze before it gets actually analyzed.
  
      This class adds the code to select a specific output neuron.
      """
      neuron_selection_mode: str
      model_inputs: list[Tensor]
      model_output: list[Tensor]
      analysis_inputs: list[Tensor]
      stop_analysis_at_tensors: list[Tensor]
  
      neuron_selection_mode = self._neuron_selection_mode
      model_inputs = model.inputs
      model_output = model.outputs
  
      if len(model_output) > 1:
          raise ValueError(
              "Only models with one output tensor are allowed."
          )
  
      analysis_inputs = []
      stop_analysis_at_tensors = []
  
      # Flatten to form (batch_size, other_dimensions):
      if kbackend.ndim(model_output[0]) > 2:
          model_output = klayers.Flatten()(model_output)
  
      if neuron_selection_mode == "max_activation":
          inn_max = ilayers.MaxNeuronSelection(
              name="MaxNeuronSelection"
          )
          model_output = inn_max(model_output)
          self._special_helper_layers.append(inn_max)
  
      elif neuron_selection_mode == "index":
          # Creates a placeholder tensor when `dtype` is passed.
          neuron_indexing: Layer = klayers.Input(
              shape=(2,),  # infer amount of output neurons
              dtype=np.int32,
              name="iNNvestigate_neuron_indexing",
          )
          # TODO: what does _keras_history[0] do?
          self._special_helper_layers.append(
              neuron_indexing._keras_history[0]
          )
          analysis_inputs.append(neuron_indexing)
          stop_analysis_at_tensors.append(neuron_indexing)
  
          select = ilayers.NeuronSelection(name="NeuronSelection")
          model_output = select(model_output + [neuron_indexing])
          self._special_helper_layers.append(select)
      elif neuron_selection_mode == "all":
          pass
      else:
          raise NotImplementedError()
  
      inputs = model_inputs + analysis_inputs
      outputs = model_output
      model = kmodels.Model(inputs=inputs, outputs=outputs)
  
      return model, analysis_inputs, stop_analysis_at_tensors
  
imports: from __future__ import annotations
  from typing import Any
  import numpy
  import tensorflow.keras.backend
  import tensorflow.keras.layers
  import tensorflow.keras.models
  import innvestigate.backend
  import innvestigate.backend.checks
  import innvestigate.layers
  from innvestigate.analyzer.base import AnalyzerBase
  from innvestigate.backend.types import Layer, LayerCheck, Model, OptionalList, Tensor
label_desc: Use image node_id 4 for calling the AnalyzerNetworkBase obj's underlying member method code with example usage: obj._prepare_model(model) and returns: model,  analysis_inputs,  stop_analysis_at_tensors