code: def batch_norm(layer, **kwargs):
      """
      Apply batch normalization to an existing layer. This is a convenience
      function modifying an existing layer to include batch normalization: It
      will steal the layer's nonlinearity if there is one (effectively
      introducing the normalization right before the nonlinearity), remove
      the layer's bias if there is one (because it would be redundant), and add
      a :class:`BatchNormLayer` and :class:`NonlinearityLayer` on top.
  
      Parameters
      ----------
      layer : A :class:`Layer` instance
          The layer to apply the normalization to; note that it will be
          irreversibly modified as specified above
      **kwargs
          Any additional keyword arguments are passed on to the
          :class:`BatchNormLayer` constructor.
  
      Returns
      -------
      BatchNormLayer or NonlinearityLayer instance
          A batch normalization layer stacked on the given modified `layer`, or
          a nonlinearity layer stacked on top of both if `layer` was nonlinear.
  
      Examples
      --------
      Just wrap any layer into a :func:`batch_norm` call on creating it:
  
      >>> from lasagne.layers import InputLayer, DenseLayer, batch_norm
      >>> from lasagne.nonlinearities import tanh
      >>> l1 = InputLayer((64, 768))
      >>> l2 = batch_norm(DenseLayer(l1, num_units=500, nonlinearity=tanh))
  
      This introduces batch normalization right before its nonlinearity:
  
      >>> from lasagne.layers import get_all_layers
      >>> [l.__class__.__name__ for l in get_all_layers(l2)]
      ['InputLayer', 'DenseLayer', 'BatchNormLayer', 'NonlinearityLayer']
      """
      nonlinearity = getattr(layer, "nonlinearity", None)
      if nonlinearity is not None:
          layer.nonlinearity = nonlinearities.identity
      if hasattr(layer, "b") and layer.b is not None:
          del layer.params[layer.b]
          layer.b = None
      bn_name = kwargs.pop("name", None) or (
          getattr(layer, "name", None) and layer.name + "_bn"
      )
      layer = BatchNormLayer(layer, name=bn_name, **kwargs)
      if nonlinearity is not None:
          from .special import NonlinearityLayer
  
          nonlin_name = bn_name and bn_name + "_nonlin"
          layer = NonlinearityLayer(
              layer, nonlinearity, name=nonlin_name
          )
      return layer
  
imports: import theano
  import theano.tensor
  from ..None import init
  from ..None import nonlinearities
  from ..utils import int_types
  from .base import Layer
label_desc: Use image node_id 1 for calling a global function with example usage: batch_norm(layer) and returns: layer