code: def test_custom_recurrent_init_shape_error():
      # Check that the custom recurrent layer throws errors for invalid shapes
      n_batch, n_steps, n_channels, width, height = (2, 3, 4, 5, 6)
      n_out_filters = 7
      filter_shape = (3, 3)
      l_in = lasagne.layers.InputLayer(
          (n_batch, n_steps, n_channels, width, height)
      )
      l_hid_to_hid = lasagne.layers.Conv2DLayer(
          lasagne.layers.InputLayer(
              (n_batch, n_out_filters, width, height)
          ),
          n_out_filters,
          filter_shape,
          pad="same",
      )
  
      # When precompute_input == True, input_to_hidden.shape[0] must be None
      # or n_batch*n_steps
      l_in_to_hid = lasagne.layers.Conv2DLayer(
          lasagne.layers.InputLayer(
              (n_batch, n_channels, width, height)
          ),
          n_out_filters,
          filter_shape,
          pad="same",
      )
      with pytest.raises(ValueError):
          l_rec = lasagne.layers.CustomRecurrentLayer(
              l_in, l_in_to_hid, l_hid_to_hid, precompute_input=True
          )
  
      # When precompute_input = False, input_to_hidden.shape[1] must be None
      # or hidden_to_hidden.shape[1]
      l_in_to_hid = lasagne.layers.Conv2DLayer(
          lasagne.layers.InputLayer(
              (n_batch + 1, n_channels, width, height)
          ),
          n_out_filters,
          filter_shape,
          pad="same",
      )
      with pytest.raises(ValueError):
          l_rec = lasagne.layers.CustomRecurrentLayer(
              l_in, l_in_to_hid, l_hid_to_hid, precompute_input=False
          )
  
      # In any case, input_to_hidden and hidden_to_hidden's output shapes after
      # the first dimension must match
      l_in_to_hid = lasagne.layers.Conv2DLayer(
          lasagne.layers.InputLayer(
              (None, n_channels, width + 1, height)
          ),
          n_out_filters,
          filter_shape,
          pad="same",
      )
      with pytest.raises(ValueError):
          l_rec = lasagne.layers.CustomRecurrentLayer(
              l_in, l_in_to_hid, l_hid_to_hid
          )
  
      # And, the output shape of input_to_hidden must match the input shape
      # of hidden_to_hidden past the first dimension.  By not using padding,
      # the output of l_in_to_hid will be cropped, which will make the
      # shape inappropriate.
      l_in_to_hid = lasagne.layers.Conv2DLayer(
          lasagne.layers.InputLayer((None, n_channels, width, height)),
          n_out_filters,
          filter_shape,
      )
      l_hid_to_hid = lasagne.layers.Conv2DLayer(
          lasagne.layers.InputLayer(
              (n_batch, n_out_filters, width, height)
          ),
          n_out_filters,
          filter_shape,
      )
      with pytest.raises(ValueError):
          l_rec = lasagne.layers.CustomRecurrentLayer(
              l_in, l_in_to_hid, l_hid_to_hid
          )
  
imports: import pytest
  from lasagne.layers import RecurrentLayer, LSTMLayer, CustomRecurrentLayer
  from lasagne.layers import InputLayer, DenseLayer, GRULayer, Gate, Layer
  from lasagne.layers import helper
  import theano
  import theano.tensor
  import numpy
  import lasagne
  from mock import Mock
label_desc: Use image node_id 14 for calling a global function with example usage: test_custom_recurrent_init_shape_error() without return types