class_docstr: Bias module.
  
  Example Usage:
  
      >>> N, H, W, C = 1, 2, 3, 4
      >>> x = tf.random.normal([N, H, W, C])
  
      >>> scalar_bias = snt.Bias(bias_dims=[])
      >>> scalar_bias_output = scalar_bias(x)
      >>> assert scalar_bias.b.shape == []
  
  Create a bias over all non-minibatch dimensions:
  
      >>> all_bias = snt.Bias()
      >>> all_bias_output = all_bias(x)
      >>> assert all_bias.b.shape == [H, W, C]
  
  Create a bias over the last non-minibatch dimension:
  
      >>> last_bias = snt.Bias(bias_dims=[-1])
      >>> last_bias_output = last_bias(x)
      >>> assert last_bias.b.shape == [C]
  
  Create a bias over the first non-minibatch dimension:
  
      >>> first_bias = snt.Bias(bias_dims=[1])
      >>> first_bias_output = first_bias(x)
      >>> assert first_bias.b.shape == [H, 1, 1]
  
  Subtract and later add the same learned bias:
  
      >>> bias = snt.Bias()
      >>> h1 = bias(x, multiplier=-1)
      >>> h2 = bias(x)
      >>> h3 = bias(x, multiplier=-1)
      >>> reconstructed_x = bias(h3)
      >>> assert tf.reduce_all(tf.equal(x, reconstructed_x))
class_docstr_tok: ["Bias","module",".","Example","Usage",":",">",">",">","N",",","H",",","W",",","C","=","1",",","2",",","3",",","4",">",">",">","x","=","tf.random.normal","(","[","N",",","H",",","W",",","C","]",")",">",">",">","scalar_bias","=","snt.Bias","(","bias_dims=","[","]",")",">",">",">","scalar_bias_output","=","scalar_bias","(","x",")",">",">",">","assert","scalar_bias.b.shape","==","[","]","Create","a","bias","over","all","non-minibatch","dimensions",":",">",">",">","all_bias","=","snt.Bias","(",")",">",">",">","all_bias_output","=","all_bias","(","x",")",">",">",">","assert","all_bias.b.shape","==","[","H",",","W",",","C","]","Create","a","bias","over","the","last","non-minibatch","dimension",":",">",">",">","last_bias","=","snt.Bias","(","bias_dims=","[","-1","]",")",">",">",">","last_bias_output","=","last_bias","(","x",")",">",">",">","assert","last_bias.b.shape","==","[","C","]","Create","a","bias","over","the","first","non-minibatch","dimension",":",">",">",">","first_bias","=","snt.Bias","(","bias_dims=","[","1","]",")",">",">",">","first_bias_output","=","first_bias","(","x",")",">",">",">","assert","first_bias.b.shape","==","[","H",",","1",",","1","]","Subtract","and","later","add","the","same","learned","bias",":",">",">",">","bias","=","snt.Bias","(",")",">",">",">","h1","=","bias","(","x",",","multiplier=-1",")",">",">",">","h2","=","bias","(","x",")",">",">",">","h3","=","bias","(","x",",","multiplier=-1",")",">",">",">","reconstructed_x","=","bias","(","h3",")",">",">",">","assert","tf.reduce_all","(","tf.equal","(","x",",","reconstructed_x",")",")"]
docstr: Adds bias to `inputs` and optionally multiplies by `multiplier`.
  
  Args:
    inputs: A Tensor of size `[batch_size, input_size1, ...]`.
    multiplier: A scalar or Tensor which the bias term is multiplied by before
      adding it to `inputs`. Anything which works in the expression `bias *
      multiplier` is acceptable here. This may be useful if you want to add a
      bias in one place and subtract the same bias in another place via
      `multiplier=-1`.
  
  Returns:
    A Tensor of size `[batch_size, input_size1, ...]`.
docstr_tok: ["Adds","bias","to","`","inputs","`","and","optionally","multiplies","by","`","multiplier","`",".","Args",":","inputs",":","A","Tensor","of","size","`","[","batch_size",",","input_size1",",","...","]","`",".","multiplier",":","A","scalar","or","Tensor","which","the","bias","term","is","multiplied","by","before","adding","it","to","`","inputs","`",".","Anything","which","works","in","the","expression","`","bias","*","multiplier","`","is","acceptable","here",".","This","may","be","useful","if","you","want","to","add","a","bias","in","one","place","and","subtract","the","same","bias","in","another","place","via","`","multiplier=-1","`",".","Returns",":","A","Tensor","of","size","`","[","batch_size",",","input_size1",",","...","]","`","."]
code: def __call__(
      self, inputs: tf.Tensor, multiplier: types.FloatLike = None
  ):
      """Adds bias to `inputs` and optionally multiplies by `multiplier`.
  
      Args:
        inputs: A Tensor of size `[batch_size, input_size1, ...]`.
        multiplier: A scalar or Tensor which the bias term is multiplied by before
          adding it to `inputs`. Anything which works in the expression `bias *
          multiplier` is acceptable here. This may be useful if you want to add a
          bias in one place and subtract the same bias in another place via
          `multiplier=-1`.
  
      Returns:
        A Tensor of size `[batch_size, input_size1, ...]`.
      """
      self._initialize(inputs)
      if multiplier is not None:
          return inputs + (self.b * multiplier)
      else:
          return inputs + self.b
  
file_path: sonnet/sonnet/src/bias.py
imports: from typing import Optional, Sequence
  from sonnet.src import base
  from sonnet.src import initializers
  from sonnet.src import once
  from sonnet.src import types
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 3 for calling the Bias obj's underlying member method code with example usage: obj.__call__(inputs, multiplier) and returns: unknown, unknown