class_docstr: Base class for speaker models.
class_docstr_tok: ["Base","class","for","speaker","models","."]
docstr: Add a pooling layer across the whole utterance.
  Input: [B, T, D]
    --> Reduce along T
  
  Statistics pooling output: [B, D * 2]
  Average pooling output: [B, D]
docstr_tok: ["Add","a","pooling","layer","across","the","whole","utterance",".","Input",":","[","B",",","T",",","D","]","--",">","Reduce","along","T","Statistics","pooling","output",":","[","B",",","D","*","2","]","Average","pooling","output",":","[","B",",","D","]"]
code: def pooling_layer(self, x, pooling_type=None):
      """
      Add a pooling layer across the whole utterance.
      Input: [B, T, D]
        --> Reduce along T
  
      Statistics pooling output: [B, D * 2]
      Average pooling output: [B, D]
      """
      assert_rank3 = tf.debugging.assert_rank(x, 3)
      with tf.control_dependencies([assert_rank3]):
          x = tf.identity(x)
  
      pooling_type = (
          pooling_type
          if pooling_type
          else self.netconf["frame_pooling_type"]
      )
      if pooling_type == "stats":
          with tf.name_scope("stats_pooling"):
              mean, var = tf.nn.moments(x, 1)
              x = tf.concat([mean, tf.sqrt(var + 1e-6)], 1)
      elif pooling_type == "average":
          with tf.name_scope("average_pooling"):
              mean, _ = tf.nn.moments(x, 1)
              x = mean
      else:
          raise ValueError(
              "Unsupported frame_pooling_type: %s" % (pooling_type)
          )
  
      assert_rank2 = tf.debugging.assert_rank(x, 2)
      with tf.control_dependencies([assert_rank2]):
          x = tf.identity(x)
  
      return x
  
imports: import math
  from absl import logging
  import delta.compat
  import tensorflow.keras.layers
  from delta import utils
  from delta.layers import common_layers
  from delta.models.base_model import RawModel
  from delta.utils.register import registers
  from delta.utils.loss.loss_utils import arcface_loss
  from delta.utils.hparam import HParams
label_desc: Use image node_id 7 for calling the SpeakerBaseRawModel obj's underlying member method code with example usage: obj.pooling_layer(x, pooling_type) and returns: x