def _replace_event_shape_in_shape_tensor(<EOL>input_shape, event_shape_in, event_shape_out, validate_args):
output_tensorshape, is_validated = _replace_event_shape_in_tensorshape(<EOL>tensorshape_util.constant_value_as_shape(input_shape),<EOL>event_shape_in,<EOL>event_shape_out)<EOL>validation_dependencies = (<EOL>map(tf.identity, (event_shape_in, event_shape_out))<EOL>if validate_args else ())<EOL>if (tensorshape_util.is_fully_defined(output_tensorshape) and<EOL>(is_validated or not validate_args)):<EOL><INDENT>with tf.control_dependencies(validation_dependencies):<EOL><INDENT>output_shape = tf.convert_to_tensor(<EOL>value=output_tensorshape, name='<STR_LIT>', dtype_hint=tf.int32)<EOL><DEDENT>return output_shape, output_tensorshape<EOL><DEDENT>with tf.control_dependencies(validation_dependencies):<EOL><INDENT>event_shape_in_ndims = (<EOL>tf.size(input=event_shape_in)<EOL>if tensorshape_util.num_elements(event_shape_in.shape) is None else<EOL>tensorshape_util.num_elements(event_shape_in.shape))<EOL>input_non_event_shape, input_event_shape = tf.split(<EOL>input_shape, num_or_size_splits=[-<NUM_LIT:1>, event_shape_in_ndims])<EOL><DEDENT>additional_assertions = []<EOL>if is_validated:<EOL><INDENT>pass<EOL><DEDENT>elif validate_args:<EOL><INDENT>mask = event_shape_in >= <NUM_LIT:0><EOL>explicit_input_event_shape = tf.boolean_mask(<EOL>tensor=input_event_shape, mask=mask)<EOL>explicit_event_shape_in = tf.boolean_mask(<EOL>tensor=event_shape_in, mask=mask)<EOL>additional_assertions.append(<EOL>assert_util.assert_equal(<EOL>explicit_input_event_shape,<EOL>explicit_event_shape_in,<EOL>message='<STR_LIT>'))<EOL><DEDENT>with tf.control_dependencies(additional_assertions):<EOL><INDENT>output_shape = tf.concat([input_non_event_shape, event_shape_out], axis=<NUM_LIT:0>,<EOL>name='<STR_LIT>')<EOL><DEDENT>return output_shape, output_tensorshape<EOL>
Replaces the rightmost dims in a `Tensor` representing a shape.

    Args:
      input_shape: a rank-1 `Tensor` of integers
      event_shape_in: the event shape expected to be present in rightmost dims
        of `shape_in`.
      event_shape_out: the event shape with which to replace `event_shape_in` in
        the rightmost dims of `input_shape`.
      validate_args: Python `bool` indicating whether arguments should
        be checked for correctness.

    Returns:
      output_shape: A rank-1 integer `Tensor` with the same contents as
        `input_shape` except for the event dims, which are replaced with
        `event_shape_out`.