class_docstr: A dense (a.k.a. fully-connected, affine) layer.
  
  Dense layers are the prototypical example of a trainable layer, i.e., a layer
  with trainable weights. Each node in a dense layer computes a weighted sum of
  all node values from the preceding layer and adds to that sum a node-specific
  bias term. The full layer computation is expressed compactly in linear
  algebra as an affine map `y = Wx + b`, where `W` is a matrix and `y`, `x`,
  and `b` are vectors. The layer is trained, or "learns", by updating the
  values in `W` and `b`.
  
  Less commonly, a dense layer can omit the bias term and be a pure linear map:
  `y = Wx`.
class_docstr_tok: ["A","dense","(","a.k.a",".","fully-connected",",","affine",")","layer",".","Dense","layers","are","the","prototypical","example","of","a","trainable","layer",",","i.e.",",","a","layer","with","trainable","weights",".","Each","node","in","a","dense","layer","computes","a","weighted","sum","of","all","node","values","from","the","preceding","layer","and","adds","to","that","sum","a","node-specific","bias","term",".","The","full","layer","computation","is","expressed","compactly","in","linear","algebra","as","an","affine","map","`","y","=","Wx","+","b","`",",","where","`","W","`","is","a","matrix","and","`","y","`",",","`","x","`",",","and","`","b","`","are","vectors",".","The","layer","is","trained",",","or","``","learns","''",",","by","updating","the","values","in","`","W","`","and","`","b","`",".","Less","commonly",",","a","dense","layer","can","omit","the","bias","term","and","be","a","pure","linear","map",":","`","y","=","Wx","`","."]
docstr: Executes this layer as part of a forward pass through the model.
  
  Args:
    x: Tensor of same shape and dtype as the input signature used to
        initialize this layer.
  
  Returns:
    Tensor of same shape and dtype as the input, except the final dimension
    is the layer's `n_units` value.
docstr_tok: ["Executes","this","layer","as","part","of","a","forward","pass","through","the","model",".","Args",":","x",":","Tensor","of","same","shape","and","dtype","as","the","input","signature","used","to","initialize","this","layer",".","Returns",":","Tensor","of","same","shape","and","dtype","as","the","input",",","except","the","final","dimension","is","the","layer","'s","`","n_units","`","value","."]
code: def forward(self, x):
      """Executes this layer as part of a forward pass through the model.
  
      Args:
        x: Tensor of same shape and dtype as the input signature used to
            initialize this layer.
  
      Returns:
        Tensor of same shape and dtype as the input, except the final dimension
        is the layer's `n_units` value.
      """
      if self._use_bias:
          if not isinstance(self.weights, (tuple, list)):
              raise ValueError(
                  f"Weights should be a (w, b) tuple or list; "
                  f"instead got: {self.weights}"
              )
          w, b = self.weights
          return jnp.dot(x, w) + b  # Affine map.
      else:
          w = self.weights
          return jnp.dot(x, w)
  
imports: from absl import logging
  import numpy
  import tensorflow
  from trax import fastmath
  from trax.fastmath import numpy
  from trax.layers import base
  from trax.layers import initializers
  from trax.layers.assert_shape import assert_shape
  from trax.layers.base import Fn
label_desc: Use image node_id 2 for calling the Dense obj's underlying member method code with example usage: obj.forward(x) and returns: unknown, jnp