class_docstr: Sonnet module squashing real-valued inputs to match a BoundedArraySpec.
class_docstr_tok: ["Sonnet","module","squashing","real-valued","inputs","to","match","a","BoundedArraySpec","."]
code: def __call__(
      self, inputs: Union[tf.Tensor, tfd.Distribution]
  ) -> Union[tf.Tensor, tfd.Distribution]:
      if isinstance(inputs, tfd.Distribution):
          inputs = tfb.Tanh()(inputs)
          inputs = tfb.ScaleMatvecDiag(0.5 * self._scale)(inputs)
          output = tfb.Shift(self._offset + 0.5 * self._scale)(inputs)
      else:
          inputs = tf.tanh(inputs)  # [-1, 1]
          inputs = 0.5 * (inputs + 1.0)  # [0, 1]
          output = (
              inputs * self._scale + self._offset
          )  # [minimum, maximum]
      return output
  
file_path: acme/acme/tf/networks/rescaling.py
imports: from typing import Union
  from acme import specs
  import sonnet
  import tensorflow
  import tensorflow_probability
label_desc: Use image node_id 2 for calling the TanhToSpec obj's underlying member method code with example usage: obj.__call__(inputs) and returns: output