parameters: (inputs, new_rank)
return_statement: return reshaped
docstring: Helper function for `inner_flatten`.
docstring_summary: Helper function for `inner_flatten`.
docstring_tokens: Helper function for inner_flatten .
function: def _dense_inner_flatten(inputs, new_rank):
    """Helper function for `inner_flatten`."""
    rank_assertion = check_ops.assert_rank_at_least(
        inputs, new_rank, message='inputs has rank less than new_rank')
    with ops.control_dependencies([rank_assertion]):
      outer_dimensions = array_ops.strided_slice(
          array_ops.shape(inputs), [0], [new_rank - 1])
      new_shape = array_ops.concat((outer_dimensions, [-1]), 0)
      reshaped = array_ops.reshape(inputs, new_shape)
  
    # if `new_rank` is an integer, try to calculate new shape.
    if isinstance(new_rank, six.integer_types):
      static_shape = inputs.get_shape()
      if static_shape is not None and static_shape.dims is not None:
        static_shape = static_shape.as_list()
        static_outer_dims = static_shape[:new_rank - 1]
        static_inner_dims = static_shape[new_rank - 1:]
        flattened_dimension = 1
        for inner_dim in static_inner_dims:
          if inner_dim is None:
            flattened_dimension = None
            break
          flattened_dimension *= inner_dim
        reshaped.set_shape(static_outer_dims + [flattened_dimension])
    return reshaped
function_tokens: def _dense_inner_flatten ( inputs , new_rank ) : rank_assertion = check_ops . assert_rank_at_least ( inputs , new_rank , message = 'inputs has rank less than new_rank' ) with ops . control_dependencies ( [ rank_assertion ] ) : outer_dimensions = array_ops . strided_slice ( array_ops . shape ( inputs ) , [ 0 ] , [ new_rank - 1 ] ) new_shape = array_ops . concat ( ( outer_dimensions , [ - 1 ] ) , 0 ) reshaped = array_ops . reshape ( inputs , new_shape ) # if `new_rank` is an integer, try to calculate new shape. if isinstance ( new_rank , six . integer_types ) : static_shape = inputs . get_shape ( ) if static_shape is not None and static_shape . dims is not None : static_shape = static_shape . as_list ( ) static_outer_dims = static_shape [ : new_rank - 1 ] static_inner_dims = static_shape [ new_rank - 1 : ] flattened_dimension = 1 for inner_dim in static_inner_dims : if inner_dim is None : flattened_dimension = None break flattened_dimension *= inner_dim reshaped . set_shape ( static_outer_dims + [ flattened_dimension ] ) return reshaped