class_docstr: Interface for tensorflow models.
docstr: Compute the model's internal representation of input x.
  In practice, this means, executing a forward pass and then, capturing the output of layers (of interest).
  As the exact definition of "internal model representation" is left out in the original paper (see: https://arxiv.org/pdf/2203.06877.pdf),
  we make the implementation flexible.
  It is up to the user whether all layers are used, or specific ones should be selected.
  The user can therefore select a layer by providing 'layer_names' (exclusive) or 'layer_indices'.
  
  Parameters
  ----------
  x: np.ndarray
      4D tensor, a batch of input datapoints
  layer_names: List[str]
      List with names of layers, from which output should be captured.
  layer_indices: List[int]
      List with indices of layers, from which output should be captured.
      Intended to use in case, when layer names are not unique, or unknown.
  
  Returns
  -------
  L: np.ndarray
      2D tensor with shape (batch_size, None)
docstr_tok: ["Compute","the","model","'s","internal","representation","of","input","x",".","In","practice",",","this","means",",","executing","a","forward","pass","and","then",",","capturing","the","output","of","layers","(","of","interest",")",".","As","the","exact","definition","of","``","internal","model","representation","''","is","left","out","in","the","original","paper","(","see",":","https",":","\/\/arxiv.org\/pdf\/2203.06877.pdf",")",",","we","make","the","implementation","flexible",".","It","is","up","to","the","user","whether","all","layers","are","used",",","or","specific","ones","should","be","selected",".","The","user","can","therefore","select","a","layer","by","providing","'layer_names","'","(","exclusive",")","or","'layer_indices","'",".","Parameters","--","--","--","--","--","x",":","np.ndarray","4D","tensor",",","a","batch","of","input","datapoints","layer_names",":","List","[","str","]","List","with","names","of","layers",",","from","which","output","should","be","captured",".","layer_indices",":","List","[","int","]","List","with","indices","of","layers",",","from","which","output","should","be","captured",".","Intended","to","use","in","case",",","when","layer","names","are","not","unique",",","or","unknown",".","Returns","--","--","--","-","L",":","np.ndarray","2D","tensor","with","shape","(","batch_size",",","None",")"]
code: def get_hidden_representations(
      self,
      x: np.ndarray,
      layer_names: Optional[List[str]] = None,
      layer_indices: Optional[List[int]] = None,
      **kwargs,
  ) -> np.ndarray:
      """
      Compute the model's internal representation of input x.
      In practice, this means, executing a forward pass and then, capturing the output of layers (of interest).
      As the exact definition of "internal model representation" is left out in the original paper (see: https://arxiv.org/pdf/2203.06877.pdf),
      we make the implementation flexible.
      It is up to the user whether all layers are used, or specific ones should be selected.
      The user can therefore select a layer by providing 'layer_names' (exclusive) or 'layer_indices'.
  
      Parameters
      ----------
      x: np.ndarray
          4D tensor, a batch of input datapoints
      layer_names: List[str]
          List with names of layers, from which output should be captured.
      layer_indices: List[int]
          List with indices of layers, from which output should be captured.
          Intended to use in case, when layer names are not unique, or unknown.
  
      Returns
      -------
      L: np.ndarray
          2D tensor with shape (batch_size, None)
      """
  
      num_layers = len(self.model.layers)
  
      if layer_indices is None:
          layer_indices = []
  
      # E.g., user can provide index -1, in order to get only representations of the last layer.
      # E.g., for 7 layers in total, this would correspond to positive index 6.
      positive_layer_indices = [
          i if i >= 0 else num_layers + i for i in layer_indices
      ]
      if layer_names is None:
          layer_names = []
  
      # List is not hashable, so we pass names + indices as tuples.
      hidden_representation_model = (
          self._build_hidden_representation_model(
              tuple(layer_names), tuple(positive_layer_indices)
          )
      )
      predict_kwargs = self._get_predict_kwargs(**kwargs)
      internal_representation = hidden_representation_model.predict(
          x, **predict_kwargs
      )
      input_batch_size = x.shape[0]
  
      # If we requested outputs only of 1 layer, keras will already return np.ndarray.
      # Otherwise, keras returns a List of np.ndarray's.
      if isinstance(internal_representation, np.ndarray):
          return internal_representation.reshape((input_batch_size, -1))
  
      internal_representation = [
          i.reshape((input_batch_size, -1))
          for i in internal_representation
      ]
      return np.hstack(internal_representation)
  
imports: from __future__ import annotations
  from typing import Dict, Optional, Tuple, List, Union, Generator
  from keras.layers import Dense
  from keras import activations
  from keras import Model
  from keras.models import clone_model
  import numpy
  import tensorflow
  from warnings import warn
  from cachetools import cachedmethod, LRUCache
  import operator
  from quantus.helpers.model.model_interface import ModelInterface
  from quantus.helpers import utils
label_desc: Use image node_id 15 for calling the TensorFlowModel obj's underlying member method code with example usage: obj.get_hidden_representations(x, layer_names, layer_indices) and returns: np, internal_representation