class_docstr: Base class for convolutional-recurrent layers.
  
  Args:
    cell: A RNN cell instance. A RNN cell is a class that has:
      - a `call(input_at_t, states_at_t)` method, returning
        `(output_at_t, states_at_t_plus_1)`. The call method of the
        cell can also take the optional argument `constants`, see
        section "Note on passing external constants" below.
      - a `state_size` attribute. This can be a single integer
        (single state) in which case it is
        the number of channels of the recurrent state
        (which should be the same as the number of channels of the cell
        output). This can also be a list/tuple of integers
        (one size per state). In this case, the first entry
        (`state_size[0]`) should be the same as
        the size of the cell output.
    return_sequences: Boolean. Whether to return the last output.
      in the output sequence, or the full sequence.
    return_state: Boolean. Whether to return the last state
      in addition to the output.
    go_backwards: Boolean (default False).
      If True, process the input sequence backwards and return the
      reversed sequence.
    stateful: Boolean (default False). If True, the last state
      for each sample at index i in a batch will be used as initial
      state for the sample of index i in the following batch.
    input_shape: Use this argument to specify the shape of the
      input when this layer is the first one in a model.
  
  Call arguments:
    inputs: A 5D tensor.
    mask: Binary tensor of shape `(samples, timesteps)` indicating whether
      a given timestep should be masked.
    training: Python boolean indicating whether the layer should behave in
      training mode or in inference mode. This argument is passed to the cell
      when calling it. This is for use with cells that use dropout.
    initial_state: List of initial state tensors to be passed to the first
      call of the cell.
    constants: List of constant tensors to be passed to the cell at each
      timestep.
  
  Input shape:
    5D tensor with shape:
    `(samples, timesteps, channels, rows, cols)`
    if data_format='channels_first' or 5D tensor with shape:
    `(samples, timesteps, rows, cols, channels)`
    if data_format='channels_last'.
  
  Output shape:
    - If `return_state`: a list of tensors. The first tensor is
      the output. The remaining tensors are the last states,
      each 4D tensor with shape:
      `(samples, filters, new_rows, new_cols)`
      if data_format='channels_first'
      or 4D tensor with shape:
      `(samples, new_rows, new_cols, filters)`
      if data_format='channels_last'.
      `rows` and `cols` values might have changed due to padding.
    - If `return_sequences`: 5D tensor with shape:
      `(samples, timesteps, filters, new_rows, new_cols)`
      if data_format='channels_first'
      or 5D tensor with shape:
      `(samples, timesteps, new_rows, new_cols, filters)`
      if data_format='channels_last'.
    - Else, 4D tensor with shape:
      `(samples, filters, new_rows, new_cols)`
      if data_format='channels_first'
      or 4D tensor with shape:
      `(samples, new_rows, new_cols, filters)`
      if data_format='channels_last'.
  
  Masking:
    This layer supports masking for input data with a variable number
    of timesteps.
  
  Note on using statefulness in RNNs:
    You can set RNN layers to be 'stateful', which means that the states
    computed for the samples in one batch will be reused as initial states
    for the samples in the next batch. This assumes a one-to-one mapping
    between samples in different successive batches.
    To enable statefulness:
      - Specify `stateful=True` in the layer constructor.
      - Specify a fixed batch size for your model, by passing
         - If sequential model:
            `batch_input_shape=(...)` to the first layer in your model.
         - If functional model with 1 or more Input layers:
            `batch_shape=(...)` to all the first layers in your model.
            This is the expected shape of your inputs
            *including the batch size*.
            It should be a tuple of integers,
            e.g. `(32, 10, 100, 100, 32)`.
            Note that the number of rows and columns should be specified
            too.
      - Specify `shuffle=False` when calling fit().
    To reset the states of your model, call `.reset_states()` on either
    a specific layer, or on your entire model.
  
  Note on specifying the initial state of RNNs:
    You can specify the initial state of RNN layers symbolically by
    calling them with the keyword argument `initial_state`. The value of
    `initial_state` should be a tensor or list of tensors representing
    the initial state of the RNN layer.
    You can specify the initial state of RNN layers numerically by
    calling `reset_states` with the keyword argument `states`. The value of
    `states` should be a numpy array or list of numpy arrays representing
    the initial state of the RNN layer.
  
  Note on passing external constants to RNNs:
    You can pass "external" constants to the cell using the `constants`
    keyword argument of `RNN.__call__` (as well as `RNN.call`) method. This
    requires that the `cell.call` method accepts the same keyword argument
    `constants`. Such constants can be used to condition the cell
    transformation on additional static inputs (not changing over time),
    a.k.a. an attention mechanism.
class_docstr_tok: ["Base","class","for","convolutional-recurrent","layers",".","Args",":","cell",":","A","RNN","cell","instance",".","A","RNN","cell","is","a","class","that","has",":","-","a","`","call","(","input_at_t",",","states_at_t",")","`","method",",","returning","`","(","output_at_t",",","states_at_t_plus_1",")","`",".","The","call","method","of","the","cell","can","also","take","the","optional","argument","`","constants","`",",","see","section","``","Note","on","passing","external","constants","''","below",".","-","a","`","state_size","`","attribute",".","This","can","be","a","single","integer","(","single","state",")","in","which","case","it","is","the","number","of","channels","of","the","recurrent","state","(","which","should","be","the","same","as","the","number","of","channels","of","the","cell","output",")",".","This","can","also","be","a","list\/tuple","of","integers","(","one","size","per","state",")",".","In","this","case",",","the","first","entry","(","`","state_size","[","0","]","`",")","should","be","the","same","as","the","size","of","the","cell","output",".","return_sequences",":","Boolean",".","Whether","to","return","the","last","output",".","in","the","output","sequence",",","or","the","full","sequence",".","return_state",":","Boolean",".","Whether","to","return","the","last","state","in","addition","to","the","output",".","go_backwards",":","Boolean","(","default","False",")",".","If","True",",","process","the","input","sequence","backwards","and","return","the","reversed","sequence",".","stateful",":","Boolean","(","default","False",")",".","If","True",",","the","last","state","for","each","sample","at","index","i","in","a","batch","will","be","used","as","initial","state","for","the","sample","of","index","i","in","the","following","batch",".","input_shape",":","Use","this","argument","to","specify","the","shape","of","the","input","when","this","layer","is","the","first","one","in","a","model",".","Call","arguments",":","inputs",":","A","5D","tensor",".","mask",":","Binary","tensor","of","shape","`","(","samples",",","timesteps",")","`","indicating","whether","a","given","timestep","should","be","masked",".","training",":","Python","boolean","indicating","whether","the","layer","should","behave","in","training","mode","or","in","inference","mode",".","This","argument","is","passed","to","the","cell","when","calling","it",".","This","is","for","use","with","cells","that","use","dropout",".","initial_state",":","List","of","initial","state","tensors","to","be","passed","to","the","first","call","of","the","cell",".","constants",":","List","of","constant","tensors","to","be","passed","to","the","cell","at","each","timestep",".","Input","shape",":","5D","tensor","with","shape",":","`","(","samples",",","timesteps",",","channels",",","rows",",","cols",")","`","if","data_format='channels_first","'","or","5D","tensor","with","shape",":","`","(","samples",",","timesteps",",","rows",",","cols",",","channels",")","`","if","data_format='channels_last","'",".","Output","shape",":","-","If","`","return_state","`",":","a","list","of","tensors",".","The","first","tensor","is","the","output",".","The","remaining","tensors","are","the","last","states",",","each","4D","tensor","with","shape",":","`","(","samples",",","filters",",","new_rows",",","new_cols",")","`","if","data_format='channels_first'","or","4D","tensor","with","shape",":","`","(","samples",",","new_rows",",","new_cols",",","filters",")","`","if","data_format='channels_last","'",".","`","rows","`","and","`","cols","`","values","might","have","changed","due","to","padding",".","-","If","`","return_sequences","`",":","5D","tensor","with","shape",":","`","(","samples",",","timesteps",",","filters",",","new_rows",",","new_cols",")","`","if","data_format='channels_first'","or","5D","tensor","with","shape",":","`","(","samples",",","timesteps",",","new_rows",",","new_cols",",","filters",")","`","if","data_format='channels_last","'",".","-","Else",",","4D","tensor","with","shape",":","`","(","samples",",","filters",",","new_rows",",","new_cols",")","`","if","data_format='channels_first'","or","4D","tensor","with","shape",":","`","(","samples",",","new_rows",",","new_cols",",","filters",")","`","if","data_format='channels_last","'",".","Masking",":","This","layer","supports","masking","for","input","data","with","a","variable","number","of","timesteps",".","Note","on","using","statefulness","in","RNNs",":","You","can","set","RNN","layers","to","be","'stateful","'",",","which","means","that","the","states","computed","for","the","samples","in","one","batch","will","be","reused","as","initial","states","for","the","samples","in","the","next","batch",".","This","assumes","a","one-to-one","mapping","between","samples","in","different","successive","batches",".","To","enable","statefulness",":","-","Specify","`","stateful=True","`","in","the","layer","constructor",".","-","Specify","a","fixed","batch","size","for","your","model",",","by","passing","-","If","sequential","model",":","`","batch_input_shape=","(","...",")","`","to","the","first","layer","in","your","model",".","-","If","functional","model","with","1","or","more","Input","layers",":","`","batch_shape=","(","...",")","`","to","all","the","first","layers","in","your","model",".","This","is","the","expected","shape","of","your","inputs","*","including","the","batch","size","*",".","It","should","be","a","tuple","of","integers",",","e.g",".","`","(","32",",","10",",","100",",","100",",","32",")","`",".","Note","that","the","number","of","rows","and","columns","should","be","specified","too",".","-","Specify","`","shuffle=False","`","when","calling","fit","(",")",".","To","reset","the","states","of","your","model",",","call","`",".reset_states","(",")","`","on","either","a","specific","layer",",","or","on","your","entire","model",".","Note","on","specifying","the","initial","state","of","RNNs",":","You","can","specify","the","initial","state","of","RNN","layers","symbolically","by","calling","them","with","the","keyword","argument","`","initial_state","`",".","The","value","of","`","initial_state","`","should","be","a","tensor","or","list","of","tensors","representing","the","initial","state","of","the","RNN","layer",".","You","can","specify","the","initial","state","of","RNN","layers","numerically","by","calling","`","reset_states","`","with","the","keyword","argument","`","states","`",".","The","value","of","`","states","`","should","be","a","numpy","array","or","list","of","numpy","arrays","representing","the","initial","state","of","the","RNN","layer",".","Note","on","passing","external","constants","to","RNNs",":","You","can","pass","``","external","''","constants","to","the","cell","using","the","`","constants","`","keyword","argument","of","`","RNN.__call__","`","(","as","well","as","`","RNN.call","`",")","method",".","This","requires","that","the","`","cell.call","`","method","accepts","the","same","keyword","argument","`","constants","`",".","Such","constants","can","be","used","to","condition","the","cell","transformation","on","additional","static","inputs","(","not","changing","over","time",")",",","a.k.a",".","an","attention","mechanism","."]
code: def build(self, input_shape):
      # Note input_shape will be list of shapes of initial states and
      # constants if these are passed in __call__.
      if self._num_constants is not None:
          constants_shape = input_shape[
              -self._num_constants :
          ]  # pylint: disable=E1130
      else:
          constants_shape = None
  
      if isinstance(input_shape, list):
          input_shape = input_shape[0]
  
      batch_size = input_shape[0] if self.stateful else None
      self.input_spec[0] = InputSpec(
          shape=(batch_size, None) + input_shape[2:5]
      )
  
      # allow cell (if layer) to build before we set or validate state_spec
      if isinstance(self.cell, Layer):
          step_input_shape = (input_shape[0],) + input_shape[2:]
          if constants_shape is not None:
              self.cell.build([step_input_shape] + constants_shape)
          else:
              self.cell.build(step_input_shape)
  
      # set or validate state_spec
      if hasattr(self.cell.state_size, "__len__"):
          state_size = list(self.cell.state_size)
      else:
          state_size = [self.cell.state_size]
  
      if self.state_spec is not None:
          # initial_state was passed in call, check compatibility
          if self.cell.data_format == "channels_first":
              ch_dim = 1
          elif self.cell.data_format == "channels_last":
              ch_dim = 3
          if [
              spec.shape[ch_dim] for spec in self.state_spec
          ] != state_size:
              raise ValueError(
                  "An initial_state was passed that is not compatible with "
                  "`cell.state_size`. Received `state_spec`={}; "
                  "However `cell.state_size` is "
                  "{}".format(
                      [spec.shape for spec in self.state_spec],
                      self.cell.state_size,
                  )
              )
      else:
          if self.cell.data_format == "channels_first":
              self.state_spec = [
                  InputSpec(shape=(None, dim, None, None))
                  for dim in state_size
              ]
          elif self.cell.data_format == "channels_last":
              self.state_spec = [
                  InputSpec(shape=(None, None, None, dim))
                  for dim in state_size
              ]
      if self.stateful:
          self.reset_states()
      self.built = True
  
imports: import numpy
  from tensorflow.python.keras import activations
  from tensorflow.python.keras import backend
  from tensorflow.python.keras import constraints
  from tensorflow.python.keras import initializers
  from tensorflow.python.keras import regularizers
  from tensorflow.python.keras.engine.base_layer import Layer
  from tensorflow.python.keras.engine.input_spec import InputSpec
  from tensorflow.python.keras.layers.recurrent import DropoutRNNCellMixin
  from tensorflow.python.keras.layers.recurrent import RNN
  from tensorflow.python.keras.utils import conv_utils
  from tensorflow.python.keras.utils import generic_utils
  from tensorflow.python.keras.utils import tf_utils
  from tensorflow.python.ops import array_ops
label_desc: Use image node_id 3 for calling the ConvRNN2D obj's underlying member method code with example usage: obj.build(input_shape) without return types