code: def define_instance_norm(tf_input, tf_index, weights, prefix):
      """
      This function defines the indexed instance norm node the tensorflow nn api.
  
      Parameters
      ----------
      tf_input: tensorflow.Tensor
          The input tensor to the instance norm node. Data format expected to be
          in `NHWC`
  
      tf_index: tensorflow.Tensor
          The index tensor to the instance norm node.
      prefix: string
          The prefix column is used to prefix the variables of the instance norm
          node for weight export.
      weights: dictionary
          The dictionary of weights to the network. The naming convention
          used is that from the CoreML export of the Style Transfer Network.
      Returns
      -------
      out: tensorflow.Tensor
          The instance norm output tensor to the network.
      """
      epsilon = 1e-5
  
      gamma = weights[prefix + "gamma_weight"]
      beta = weights[prefix + "beta_weight"]
  
      inputs_rank = tf_input.shape.ndims
      reduction_axis = inputs_rank - 1
      moments_axes = list(range(inputs_rank))
  
      del moments_axes[reduction_axis]
      del moments_axes[0]
  
      _tf = _lazy_import_tensorflow()
  
      indexed_gamma = _tf.gather(gamma, tf_index)
      indexed_beta = _tf.gather(beta, tf_index)
  
      expanded_gamma = _tf.expand_dims(
          _tf.expand_dims(indexed_gamma, 1), 1
      )
      expanded_beta = _tf.expand_dims(
          _tf.expand_dims(indexed_beta, 1), 1
      )
  
      mean, variance = _tf.nn.moments(
          tf_input, moments_axes, keep_dims=True
      )
      return _tf.nn.batch_normalization(
          tf_input,
          mean,
          variance,
          expanded_beta,
          expanded_gamma,
          epsilon,
      )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from turicreate.toolkits._tf_model import TensorFlowModel
  import numpy
  import turicreate.toolkits._tf_utils
  from turicreate._deps.minimal_package import _minimal_package_import_check
label_desc: Use image node_id 3 for calling a global function with example usage: define_instance_norm(tf_input, tf_index, weights, prefix) and returns: _tf