code: def _reshape_inner_dims(
      tensor: tf.Tensor,
      shape: tf.TensorShape,
      new_shape: tf.TensorShape,
  ) -> tf.Tensor:
      """Reshapes tensor to: shape(tensor)[:-len(shape)] + new_shape."""
      tensor_shape = tf.shape(tensor)
      ndims = shape.rank
      tensor.shape[-ndims:].assert_is_compatible_with(shape)
      new_shape_inner_tensor = tf.cast(
          [-1 if d is None else d for d in new_shape.as_list()],
          tf.int32,
      )
      new_shape_outer_tensor = tf.cast(tensor_shape[:-ndims], tf.int32)
      full_new_shape = tf.concat(
          (new_shape_outer_tensor, new_shape_inner_tensor), axis=0
      )
      new_tensor = tf.reshape(tensor, full_new_shape)
      new_tensor.set_shape(tensor.shape[:-ndims] + new_shape)
      return new_tensor
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v2
  from tf_agents.typing import types
label_desc: Use image node_id 2 for calling a global function with example usage: _reshape_inner_dims(tensor, shape, new_shape) and returns: new_tensor