code: def image_embedding(
      images,
      model_fn=resnet_v1_152,
      trainable=True,
      is_training=True,
      weight_decay=0.0001,
      batch_norm_decay=0.997,
      batch_norm_epsilon=1e-5,
      batch_norm_scale=True,
      add_summaries=False,
      reuse=False,
  ):
      """Extract image features from pretrained resnet model."""
  
      is_resnet_training = trainable and is_training
  
      batch_norm_params = {
          "is_training": is_resnet_training,
          "trainable": trainable,
          "decay": batch_norm_decay,
          "epsilon": batch_norm_epsilon,
          "scale": batch_norm_scale,
      }
  
      if trainable:
          weights_regularizer = contrib.layers().l2_regularizer(
              weight_decay
          )
      else:
          weights_regularizer = None
  
      with tf.variable_scope(
          model_fn.__name__, [images], reuse=reuse
      ) as scope:
          with slim.arg_scope(
              [slim.conv2d],
              weights_regularizer=weights_regularizer,
              trainable=trainable,
          ):
              with slim.arg_scope(
                  [slim.conv2d],
                  weights_initializer=slim.variance_scaling_initializer(),
                  activation_fn=tf.nn.relu,
                  normalizer_fn=slim.batch_norm,
                  normalizer_params=batch_norm_params,
              ):
                  with slim.arg_scope(
                      [slim.batch_norm],
                      is_training=is_resnet_training,
                      trainable=trainable,
                  ):
                      with slim.arg_scope(
                          [slim.max_pool2d], padding="SAME"
                      ):
                          net, end_points = model_fn(
                              images,
                              num_classes=None,
                              global_pool=False,
                              is_training=is_resnet_training,
                              reuse=reuse,
                              scope=scope,
                          )
  
      if add_summaries:
          for v in end_points.values():
              contrib.layers().summaries.summarize_activation(v)
  
      return net
  
file_path: tensor2tensor/tensor2tensor/layers/vqa_layers.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.utils import contrib
  import tensorflow.compat.v1
  from tensorflow.contrib import slim
  from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1_152
  from tensorflow.contrib.slim.python.slim.nets.resnet_v2 import resnet_v2_152
  from tensorflow.python.ops import inplace_ops
label_desc: Use image node_id 2 for calling a global function with example usage: image_embedding(images, model_fn, trainable, is_training, weight_decay, batch_norm_decay, batch_norm_epsilon, batch_norm_scale, add_summaries, reuse) and returns: net