code: def actnorm(name, x, x_mask, inverse, init, logscale_factor=3.0):
      """Activation normalization, returns logabsdet of shape [B]."""
      eps = tf.keras.backend.epsilon()
      n_channels = common_layers.shape_list(x)[2]
  
      with tf.variable_scope(name, reuse=tf.AUTO_REUSE):
          x_mean, x_var = gops.moments_over_bl(x, x_mask)
          b = gops.get_variable_ddi(
              "b", (n_channels), -x_mean, init, tf.zeros_initializer
          )
          log_w_init = -0.5 * tf.log(x_var + eps) / logscale_factor
          log_w = (
              gops.get_variable_ddi(
                  "log_w",
                  (n_channels),
                  log_w_init,
                  init,
                  tf.zeros_initializer,
              )
              * logscale_factor
          )
  
          if not inverse:
              x = (x + b) * tf.exp(log_w)
          else:
              x = x * tf.exp(-log_w) - b
  
          x_length = tf.reduce_sum(x_mask, -1)
          logabsdet = x_length * tf.reduce_sum(log_w)
          if inverse:
              logabsdet *= -1
          return x, logabsdet
  
file_path: tensor2tensor/tensor2tensor/layers/transformer_glow_layers.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import numpy
  import scipy
  from tensor2tensor.layers import common_layers
  import tensor2tensor.layers.transformer_glow_layers_ops
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: actnorm(name, x, x_mask, inverse, init, logscale_factor) and returns: x,  logabsdet