code: def get_image_generator_tf_v2(capacity: int, z_dim: int):
      import tensorflow as tf  # lgtm [py/import-and-import-from]
  
      def make_image_generator_model(
          capacity: int, z_dim: int
      ) -> tf.keras.Sequential():
          model = tf.keras.Sequential()
  
          model.add(
              tf.keras.layers.Dense(
                  capacity * 7 * 7 * 4,
                  use_bias=False,
                  input_shape=(z_dim,),
              )
          )
          model.add(tf.keras.layers.BatchNormalization())
          model.add(tf.keras.layers.LeakyReLU())
  
          model.add(tf.keras.layers.Reshape((7, 7, capacity * 4)))
          assert model.output_shape == (None, 7, 7, capacity * 4)
  
          model.add(
              tf.keras.layers.Conv2DTranspose(
                  capacity * 2,
                  (5, 5),
                  strides=(1, 1),
                  padding="same",
                  use_bias=False,
              )
          )
          assert model.output_shape == (None, 7, 7, capacity * 2)
          model.add(tf.keras.layers.BatchNormalization())
          model.add(tf.keras.layers.LeakyReLU())
  
          model.add(
              tf.keras.layers.Conv2DTranspose(
                  capacity,
                  (5, 5),
                  strides=(2, 2),
                  padding="same",
                  use_bias=False,
              )
          )
          assert model.output_shape == (None, 14, 14, capacity)
          model.add(tf.keras.layers.BatchNormalization())
          model.add(tf.keras.layers.LeakyReLU())
  
          model.add(
              tf.keras.layers.Conv2DTranspose(
                  1,
                  (5, 5),
                  strides=(2, 2),
                  padding="same",
                  use_bias=False,
              )
          )
  
          model.add(tf.keras.layers.Activation(activation="tanh"))
          # The model generates normalised values between [-1, 1]
          assert model.output_shape == (None, 28, 28, 1)
  
          return model
  
      generator = TensorFlowV2Generator(
          encoding_length=z_dim,
          model=make_image_generator_model(capacity, z_dim),
      )
  
      return generator
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import json
  import logging
  import os
  import pickle
  import time
  import unittest
  import warnings
  import sklearn
  import numpy
  from art.estimators.classification.tensorflow import TensorFlowV2Classifier
  from art.estimators.encoding.tensorflow import TensorFlowEncoder
  from art.estimators.generation.tensorflow import TensorFlowGenerator, TensorFlowV2Generator
  from art.estimators.gan.tensorflow import TensorFlowV2GAN
  from art.utils import load_dataset
label_desc: Use image node_id 9 for calling a global function with example usage: get_image_generator_tf_v2(capacity, z_dim) and returns: generator, model