class_docstr: Interface for tensorflow models.
docstr: Build a keras model, which outputs the internal representation of layers,
  specified in layer_names or layer_indices, default all.
  This requires re-tracing the model, so we cache it to improve metric evaluation time.
docstr_tok: ["Build","a","keras","model",",","which","outputs","the","internal","representation","of","layers",",","specified","in","layer_names","or","layer_indices",",","default","all",".","This","requires","re-tracing","the","model",",","so","we","cache","it","to","improve","metric","evaluation","time","."]
code: def _build_hidden_representation_model(
      self, layer_names: Tuple, layer_indices: Tuple
  ) -> Model:
      """
      Build a keras model, which outputs the internal representation of layers,
      specified in layer_names or layer_indices, default all.
      This requires re-tracing the model, so we cache it to improve metric evaluation time.
      """
      if layer_names == () and layer_indices == ():
          warn(
              "quantus.TensorFlowModel.get_hidden_layers_representations(...) received `layer_names`=None and "
              "`layer_indices`=None. This will force creation of tensorflow.keras.Model with outputs of each layer"
              " from original model. This can be very computationally expensive."
          )
  
      def is_layer_of_interest(index: int, name: str) -> bool:
          if layer_names == () and layer_indices == ():
              return True
          return index in layer_indices or name in layer_names
  
      outputs_of_interest = []
      for i, layer in enumerate(self.model.layers):
          if is_layer_of_interest(i, layer.name):
              outputs_of_interest.append(layer.output)
  
      if len(outputs_of_interest) == 0:
          raise ValueError("No hidden representations were selected.")
  
      hidden_representation_model = Model(
          self.model.input, outputs_of_interest
      )
      return hidden_representation_model
  
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 13 for calling the TensorFlowModel obj's underlying member method code with example usage: obj._build_hidden_representation_model(layer_names, layer_indices) and returns: hidden_representation_model, unknown, True