class_docstr: Construct and access Conv + (Squeeze) + BatchNorm + activation models.
class_docstr_tok: ["Construct","and","access","Conv","+","(","Squeeze",")","+","BatchNorm","+","activation","models","."]
docstr: Return nonfolded Conv2D + BN + optional activation model.
docstr_tok: ["Return","nonfolded","Conv2D","+","BN","+","optional","activation","model","."]
code: def get_nonfolded_batchnorm_model(
      cls,
      post_bn_activation=None,
      model_type="sequential",
      random_init=False,
      squeeze_type=False,
      normalization_type="BatchNormalization",
  ):
      """Return nonfolded Conv2D + BN + optional activation model."""
      if normalization_type == "BatchNormalization":
          normalization = keras.layers.BatchNormalization
      elif normalization_type == "SyncBatchNormalization":
          normalization = (
              keras.layers.experimental.SyncBatchNormalization
          )
  
      if squeeze_type == "sepconv1d_squeeze":
          squeeze_layer = tf.keras.layers.Lambda(
              lambda x: tf.squeeze(x, [1]), name="sepconv1d_squeeze_1"
          )
      else:
          squeeze_layer = None
  
      if model_type == "sequential":
          layers = []
          layers.append(
              keras.layers.Conv2D(
                  kernel_initializer=_get_initializer(random_init),
                  use_bias=False,
                  **cls.params,
              )
          )
          if squeeze_layer is not None:
              layers.append(squeeze_layer)
          layers.append(normalization(axis=-1))
          if post_bn_activation is not None:
              layers += post_bn_activation
          return tf.keras.Sequential(layers)
      else:
          inp = keras.layers.Input(
              cls.params["input_shape"], cls.params["batch_size"]
          )
          x = keras.layers.Conv2D(
              cls.params["filters"],
              cls.params["kernel_size"],
              kernel_initializer=_get_initializer(random_init),
              use_bias=False,
          )(inp)
          if squeeze_layer is not None:
              x = squeeze_layer(x)
          out = normalization(axis=-1)(x)
          if post_bn_activation is not None:
              out = post_bn_activation(out)
          return tf.keras.Model(inp, out)
  
file_path: model-optimization/tensorflow_model_optimization/python/core/quantization/keras/layers/conv_batchnorm_test_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
label_desc: Use image node_id 3 for calling the Conv2DModel obj's underlying member method code with example usage: obj.get_nonfolded_batchnorm_model(cls, post_bn_activation, model_type, random_init, squeeze_type, normalization_type) and returns: tf, tf