class_docstr: Adds TensorFlow specific functions.
docstr: Build a model from a list of keywords.
  
  A BackendEngine should implement get_model in order to
  simplify the user's work. In particular, we will adhere
  to the following API where list_nodes is a list of neural network
  layers.
  
  Parameters
  ----------
  list_nodes: list
      list of keywords. Integer keywords indicate a layer with
      a number of nodes.
      Callable keywords are added to the model as a layer directly,
      which is useful for activation functions. String keywords are
      interpreted using :code:`tensorflow.keras.activations.deserialize`.
  
  Returns
  -------
  model : tensorflow.keras.Model
      initialized model with layers as specified.
docstr_tok: ["Build","a","model","from","a","list","of","keywords",".","A","BackendEngine","should","implement","get_model","in","order","to","simplify","the","user","'s","work",".","In","particular",",","we","will","adhere","to","the","following","API","where","list_nodes","is","a","list","of","neural","network","layers",".","Parameters","--","--","--","--","--","list_nodes",":","list","list","of","keywords",".","Integer","keywords","indicate","a","layer","with","a","number","of","nodes",".","Callable","keywords","are","added","to","the","model","as","a","layer","directly",",","which","is","useful","for","activation","functions",".","String","keywords","are","interpreted","using",":","code",":","`","tensorflow.keras.activations.deserialize","`",".","Returns","--","--","--","-","model",":","tensorflow.keras.Model","initialized","model","with","layers","as","specified","."]
code: def get_model(self, list_nodes):
      """
      Build a model from a list of keywords.
  
      A BackendEngine should implement get_model in order to
      simplify the user's work. In particular, we will adhere
      to the following API where list_nodes is a list of neural network
      layers.
  
      Parameters
      ----------
      list_nodes: list
          list of keywords. Integer keywords indicate a layer with
          a number of nodes.
          Callable keywords are added to the model as a layer directly,
          which is useful for activation functions. String keywords are
          interpreted using :code:`tensorflow.keras.activations.deserialize`.
  
      Returns
      -------
      model : tensorflow.keras.Model
          initialized model with layers as specified.
      """
      initializer_w = tensorflow.keras.initializers.GlorotNormal()
  
      class FullyConnected(tensorflow.keras.Model):
          """Neural network class."""
  
          def __init__(self):
              """Initialize the layers of the NN."""
              super(FullyConnected, self).__init__()
              layers = []
              for i, item in enumerate(list_nodes):
                  if i == 0:
                      continue  # What if the first item is not an int?
                  if isinstance(item, int):
                      layers.append(
                          tensorflow.keras.layers.Dense(
                              units=item,
                              kernel_initializer=initializer_w,
                              bias_initializer="zeros",
                          )
                      )
                  elif callable(item):
                      layers.append(item)
                  elif isinstance(item, str):
                      layers.append(
                          tensorflow.keras.activations.deserialize(item)
                      )
              self.layers_ = layers
  
          def call(self, x):
              """Propagate x through the network."""
              for layer in self.layers_:
                  x = layer(x)
              return x
  
      model = FullyConnected()
  
      return model
  
file_path: fairlearn/fairlearn/adversarial/_tensorflow_engine.py
imports: from ._backend_engine import BackendEngine
  from numpy import finfo, float32
label_desc: Use image node_id 6 for calling the TensorflowEngine obj's underlying member method code with example usage: obj.get_model(list_nodes) and returns: model, x