class_docstr: Base class for speaker models.
class_docstr_tok: ["Base","class","for","speaker","models","."]
docstr: linear layer for dim reduction
  x: shape [batch, time, feat, channel]
  output: shape [b, t, f]
docstr_tok: ["linear","layer","for","dim","reduction","x",":","shape","[","batch",",","time",",","feat",",","channel","]","output",":","shape","[","b",",","t",",","f","]"]
code: def linear_block(self, x):
      """
      linear layer for dim reduction
      x: shape [batch, time, feat, channel]
      output: shape [b, t, f]
      """
      batch_t = tf.shape(x)[0]
      time_t = tf.shape(x)[1]
      feat, channel = x.shape.as_list()[2:]
      linear_num = self.netconf["linear_num"]
  
      if linear_num > 0:
          with tf.variable_scope("linear"):
              x = tf.reshape(x, [batch_t * time_t, feat * channel])
  
              if self.netconf["use_dropout"]:
                  x = tf.layers.dropout(
                      x,
                      self.netconf["dropout_rate"],
                      training=self.train,
                  )
  
              x = common_layers.linear(
                  x, "linear1", [feat * channel, linear_num]
              )
  
              x = tf.nn.relu(x)
  
              if self.netconf["use_bn"]:
                  bn_name = "bn_linear"
                  x = tf.layers.batch_normalization(
                      x,
                      axis=-1,
                      momentum=0.9,
                      training=self.train,
                      name=bn_name,
                  )
  
              x = tf.reshape(x, [batch_t, time_t, linear_num])
      else:
          logging.info("linear_num <= 0, only apply reshape.")
          x = tf.reshape(x, [batch_t, time_t, feat * channel])
  
      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 5 for calling the SpeakerBaseRawModel obj's underlying member method code with example usage: obj.linear_block(x) and returns: x