class_docstr: Reshapes input Tensor, preserving the batch dimension.
  
  For example, given an input tensor with shape ``[B, H, W, C, D]``::
  
      >>> B, H, W, C, D = range(1, 6)
      >>> x = tf.ones([B, H, W, C, D])
  
  The default behavior when ``output_shape`` is ``(-1, D)`` is to flatten
  all dimensions between ``B`` and ``D``::
  
      >>> mod = snt.Reshape(output_shape=(-1, D))
      >>> assert mod(x).shape == [B, H*W*C, D]
  
  You can change the number of preserved leading dimensions via
  ``preserve_dims``::
  
      >>> mod = snt.Reshape(output_shape=(-1, D), preserve_dims=2)
      >>> assert mod(x).shape == [B, H, W*C, D]
  
      >>> mod = snt.Reshape(output_shape=(-1, D), preserve_dims=3)
      >>> assert mod(x).shape == [B, H, W, C, D]
  
      >>> mod = snt.Reshape(output_shape=(-1, D), preserve_dims=4)
      >>> assert mod(x).shape == [B, H, W, C, 1, D]
class_docstr_tok: ["Reshapes","input","Tensor",",","preserving","the","batch","dimension",".","For","example",",","given","an","input","tensor","with","shape","``","[","B",",","H",",","W",",","C",",","D","]","``",":",":",">",">",">","B",",","H",",","W",",","C",",","D","=","range","(","1",",","6",")",">",">",">","x","=","tf.ones","(","[","B",",","H",",","W",",","C",",","D","]",")","The","default","behavior","when","``","output_shape","``","is","``","(","-1",",","D",")","``","is","to","flatten","all","dimensions","between","``","B","``","and","``","D","``",":",":",">",">",">","mod","=","snt.Reshape","(","output_shape=","(","-1",",","D",")",")",">",">",">","assert","mod","(","x",")",".shape","==","[","B",",","H","*","W","*","C",",","D","]","You","can","change","the","number","of","preserved","leading","dimensions","via","``","preserve_dims","``",":",":",">",">",">","mod","=","snt.Reshape","(","output_shape=","(","-1",",","D",")",",","preserve_dims=2",")",">",">",">","assert","mod","(","x",")",".shape","==","[","B",",","H",",","W","*","C",",","D","]",">",">",">","mod","=","snt.Reshape","(","output_shape=","(","-1",",","D",")",",","preserve_dims=3",")",">",">",">","assert","mod","(","x",")",".shape","==","[","B",",","H",",","W",",","C",",","D","]",">",">",">","mod","=","snt.Reshape","(","output_shape=","(","-1",",","D",")",",","preserve_dims=4",")",">",">",">","assert","mod","(","x",")",".shape","==","[","B",",","H",",","W",",","C",",","1",",","D","]"]
code: def _initialize(self, inputs: tf.Tensor):
      if inputs.shape.rank < self._preserve_dims:
          raise ValueError(
              "Input tensor has {} dimensions, should have at least "
              "as many as preserve_dims={}".format(
                  inputs.shape.rank, self._preserve_dims
              )
          )
  
      self._input_shape = inputs.shape
  
file_path: sonnet/sonnet/src/reshape.py
imports: from typing import Optional, Sequence
  import numpy
  from sonnet.src import base
  from sonnet.src import once
  from sonnet.src import types
  import tensorflow
label_desc: Use image node_id 2 for calling the Reshape obj's underlying member method code with example usage: obj._initialize(inputs) without return types