code: def test_layer_norm_macro():
      from lasagne.layers import (
          Layer,
          NonlinearityLayer,
          StandardizationLayer,
          ScaleLayer,
          BiasLayer,
          layer_norm,
      )
      from lasagne.nonlinearities import identity
  
      input_shape = (2, 3)
      obj = object()
  
      # check if it steals the nonlinearity and applies StandardizationLayer,
      #  ScaleLayer and BiasLayer on top of the input layer
      layer = Mock(Layer, output_shape=input_shape, nonlinearity=obj)
      lnstack = layer_norm(layer)
      assert isinstance(lnstack, NonlinearityLayer)
      assert isinstance(lnstack.input_layer, BiasLayer)
      assert isinstance(lnstack.input_layer.input_layer, ScaleLayer)
      assert isinstance(
          lnstack.input_layer.input_layer.input_layer,
          StandardizationLayer,
      )
      assert layer.nonlinearity is identity
      assert lnstack.nonlinearity is obj
  
      # check if it removes the bias
      layer = Mock(
          Layer, output_shape=input_shape, b=obj, params={obj: set()}
      )
      lnstack = layer_norm(layer)
      assert layer.b is None
      assert obj not in layer.params
  
      # check if it can handle an unset bias
      layer = Mock(
          Layer, output_shape=input_shape, b=None, params={obj: set()}
      )
      lnstack = layer_norm(layer)
      assert layer.b is None
  
      # check if it passes on kwargs
      layer = Mock(Layer, output_shape=input_shape, nonlinearity=obj)
      lnstack = layer_norm(layer, name="foo_lnorm")
      assert isinstance(lnstack, NonlinearityLayer)
      assert lnstack.name == "foo_lnorm_nonlin"
      assert isinstance(lnstack.input_layer, BiasLayer)
      assert lnstack.input_layer.name == "foo_lnorm_bias"
      assert isinstance(lnstack.input_layer.input_layer, ScaleLayer)
      assert lnstack.input_layer.input_layer.name == "foo_lnorm_scale"
      assert isinstance(
          lnstack.input_layer.input_layer.input_layer,
          StandardizationLayer,
      )
      assert (
          lnstack.input_layer.input_layer.input_layer.name
          == "foo_lnorm"
      )
  
      # check if created layers are named with kwargs name
      layer = Mock(Layer, output_shape=input_shape, nonlinearity=obj)
      layer.name = "foo"
      lnstack = layer_norm(layer, name="foo_lnorm")
      assert isinstance(lnstack, NonlinearityLayer)
      assert lnstack.name == "foo_lnorm_nonlin"
      assert isinstance(lnstack.input_layer, BiasLayer)
      assert lnstack.input_layer.name == "foo_lnorm_bias"
      assert isinstance(lnstack.input_layer.input_layer, ScaleLayer)
      assert lnstack.input_layer.input_layer.name == "foo_lnorm_scale"
      assert isinstance(
          lnstack.input_layer.input_layer.input_layer,
          StandardizationLayer,
      )
      assert (
          lnstack.input_layer.input_layer.input_layer.name
          == "foo_lnorm"
      )
  
      # check if created layers are named with wrapped layer name
      layer = Mock(Layer, output_shape=input_shape, nonlinearity=obj)
      layer.name = "foo"
      lnstack = layer_norm(layer)
      assert isinstance(lnstack, NonlinearityLayer)
      assert lnstack.name == "foo_ln_nonlin"
      assert isinstance(lnstack.input_layer, BiasLayer)
      assert lnstack.input_layer.name == "foo_ln_bias"
      assert isinstance(lnstack.input_layer.input_layer, ScaleLayer)
      assert lnstack.input_layer.input_layer.name == "foo_ln_scale"
      assert isinstance(
          lnstack.input_layer.input_layer.input_layer,
          StandardizationLayer,
      )
      assert (
          lnstack.input_layer.input_layer.input_layer.name == "foo_ln"
      )
  
      # check if created layers remain unnamed if no names are given
      layer = Mock(Layer, output_shape=input_shape, nonlinearity=obj)
      lnstack = layer_norm(layer)
      assert isinstance(lnstack, NonlinearityLayer)
      assert lnstack.name is None
      assert isinstance(lnstack.input_layer, BiasLayer)
      assert lnstack.input_layer.name is None
      assert isinstance(lnstack.input_layer.input_layer, ScaleLayer)
      assert lnstack.input_layer.input_layer.name is None
      assert isinstance(
          lnstack.input_layer.input_layer.input_layer,
          StandardizationLayer,
      )
      assert lnstack.input_layer.input_layer.input_layer.name is None
  
imports: from mock import Mock
  import numpy
  import pytest
  import theano
label_desc: Use image node_id 6 for calling a global function with example usage: test_layer_norm_macro() without return types