code: def weight_decay_and_noise(
      loss, hparams, learning_rate, var_list=None
  ):
      """Apply weight decay and weight noise."""
      if var_list is None:
          var_list = tf.trainable_variables()
  
      decay_vars = [v for v in var_list]
      noise_vars = [v for v in var_list if "/body/" in v.name]
  
      weight_decay_loss = weight_decay(hparams.weight_decay, decay_vars)
      if (
          hparams.weight_decay
          and common_layers.should_generate_summaries()
      ):
          tf.summary.scalar("losses/weight_decay", weight_decay_loss)
      weight_noise_ops = weight_noise(
          hparams.weight_noise, learning_rate, noise_vars
      )
  
      with tf.control_dependencies(weight_noise_ops):
          loss = tf.identity(loss)
  
      loss += weight_decay_loss
      return loss
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from tensor2tensor.layers import common_layers
  from tensor2tensor.utils import adafactor
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import misc_utils
  from tensor2tensor.utils import mlperf_log
  from tensor2tensor.utils import multistep_optimizer
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import yellowfin
  import tensorflow.compat.v1
  from tensorflow.python.framework import dtypes
label_desc: Use image node_id 11 for calling a global function with example usage: weight_decay_and_noise(loss, hparams, learning_rate, var_list) and returns: loss