class_docstr: Spatial GRU layer.
  
  :param units: Number of SpatialGRU units.
  :param activation: Activation function to use. Default:
      hyperbolic tangent (`tanh`). If you pass `None`, no
      activation is applied (ie. "linear" activation: `a(x) = x`).
  :param recurrent_activation: Activation function to use for
      the recurrent step. Default: sigmoid (`sigmoid`).
      If you pass `None`, no activation is applied (ie. "linear"
      activation: `a(x) = x`).
  :param kernel_initializer: Initializer for the `kernel` weights
      matrix, used for the linear transformation of the inputs.
  :param recurrent_initializer: Initializer for the `recurrent_kernel`
      weights matrix, used for the linear transformation of the
      recurrent state.
  :param direction: Scanning direction. `lt` (i.e., left top)
      indicates the scanning from left top to right bottom, and
      `rb` (i.e., right bottom) indicates the scanning from
      right bottom to left top.
  :param kwargs: Standard layer keyword arguments.
  
  Examples:
      >>> import matchzoo as mz
      >>> layer = mz.contrib.layers.SpatialGRU(units=10,
      ...                                      direction='lt')
      >>> num_batch, channel, left_len, right_len = 5, 5, 3, 2
      >>> layer.build([num_batch, channel, left_len, right_len])
class_docstr_tok: ["Spatial","GRU","layer",".",":","param","units",":","Number","of","SpatialGRU","units",".",":","param","activation",":","Activation","function","to","use",".","Default",":","hyperbolic","tangent","(","`","tanh","`",")",".","If","you","pass","`","None","`",",","no","activation","is","applied","(","ie",".","``","linear","''","activation",":","`","a","(","x",")","=","x","`",")",".",":","param","recurrent_activation",":","Activation","function","to","use","for","the","recurrent","step",".","Default",":","sigmoid","(","`","sigmoid","`",")",".","If","you","pass","`","None","`",",","no","activation","is","applied","(","ie",".","``","linear","''","activation",":","`","a","(","x",")","=","x","`",")",".",":","param","kernel_initializer",":","Initializer","for","the","`","kernel","`","weights","matrix",",","used","for","the","linear","transformation","of","the","inputs",".",":","param","recurrent_initializer",":","Initializer","for","the","`","recurrent_kernel","`","weights","matrix",",","used","for","the","linear","transformation","of","the","recurrent","state",".",":","param","direction",":","Scanning","direction",".","`","lt","`","(","i.e.",",","left","top",")","indicates","the","scanning","from","left","top","to","right","bottom",",","and","`","rb","`","(","i.e.",",","right","bottom",")","indicates","the","scanning","from","right","bottom","to","left","top",".",":","param","kwargs",":","Standard","layer","keyword","arguments",".","Examples",":",">",">",">","import","matchzoo","as","mz",">",">",">","layer","=","mz.contrib.layers.SpatialGRU","(","units=10",",","...","direction='lt","'",")",">",">",">","num_batch",",","channel",",","left_len",",","right_len","=","5",",","5",",","3",",","2",">",">",">","layer.build","(","[","num_batch",",","channel",",","left_len",",","right_len","]",")"]
docstr: Build the layer.
  
  :param input_shape: the shapes of the input tensors.
docstr_tok: ["Build","the","layer",".",":","param","input_shape",":","the","shapes","of","the","input","tensors","."]
code: def build(self, input_shape: typing.Any):
      """
      Build the layer.
  
      :param input_shape: the shapes of the input tensors.
      """
      # Scalar dimensions referenced here:
      #   B = batch size (number of sequences)
      #   L = `input_left` sequence length
      #   R = `input_right` sequence length
      #   C = number of channels
      #   U = number of units
  
      # input_shape = [B, C, L, R]
      self._batch_size = input_shape[0]
      self._channel = input_shape[1]
      self._input_dim = self._channel + 3 * self._units
  
      self._text1_maxlen = input_shape[2]
      self._text2_maxlen = input_shape[3]
      self._recurrent_step = self._text1_maxlen * self._text2_maxlen
      # W = [3*U+C, 7*U]
      self._W = self.add_weight(
          name="W",
          shape=(self._input_dim, self._units * 7),
          initializer=self._kernel_initializer,
          trainable=True,
      )
      # U = [3*U, U]
      self._U = self.add_weight(
          name="U",
          shape=(self._units * 3, self._units),
          initializer=self._recurrent_initializer,
          trainable=True,
      )
      # bias = [8*U,]
      self._bias = self.add_weight(
          name="bias",
          shape=(self._units * 8,),
          initializer="zeros",
          trainable=True,
      )
  
      # w_rl, w_rt, w_rd = [B, 3*U]
      self._wr = self._W[:, : self._units * 3]
      # b_rl, b_rt, b_rd = [B, 3*U]
      self._br = self._bias[: self._units * 3]
      # w_zi, w_zl, w_zt, w_zd = [B, 4*U]
      self._wz = self._W[:, self._units * 3 : self._units * 7]
      # b_zi, b_zl, b_zt, b_zd = [B, 4*U]
      self._bz = self._bias[self._units * 3 : self._units * 7]
      # w_ij = [C, U]
      self._w_ij = self.add_weight(
          name="W_ij",
          shape=(self._channel, self._units),
          initializer=self._recurrent_initializer,
          trainable=True,
      )
      # b_ij = [7*U]
      self._b_ij = self._bias[self._units * 7 :]
      super(SpatialGRU, self).build(input_shape)
  
file_path: MatchZoo/matchzoo/contrib/layers/spatial_gru.py
imports: import typing
  import tensorflow
  from keras import backend
  from keras.engine import Layer
  from keras.layers import Permute
  from keras.layers import Reshape
  from keras import activations
  from keras import initializers
label_desc: Use image node_id 2 for calling the SpatialGRU obj's underlying member method code with example usage: obj.build(input_shape) without return types