code: def define_gram_matrix(tf_input):
      """
      This function defines the gram_matrix computation the tensorflow nn api.
  
      Parameters
      ----------
      tf_input: tensorflow.Tensor
          The input tensor to the network. The image is expected to be in RGB
          format.
      Returns
      -------
      out: tensorflow.Tensor
          The gram matrix output of the network.
      """
      _tf = _lazy_import_tensorflow()
  
      defined_shape = _tf.shape(tf_input)
      reshaped_output = _tf.reshape(
          tf_input,
          [-1, defined_shape[1] * defined_shape[2], defined_shape[3]],
      )
      reshaped_output_transposed = _tf.transpose(
          reshaped_output, perm=[0, 2, 1]
      )
      multiplied_out = _tf.matmul(
          reshaped_output_transposed, reshaped_output
      )
      normalized_out = multiplied_out / _tf.cast(
          defined_shape[1] * defined_shape[2], dtype=_tf.float32
      )
  
      return normalized_out
  
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 8 for calling a global function with example usage: define_gram_matrix(tf_input) and returns: normalized_out