NEED HELP!question about Tilemaplayer making 2d mountain

I am working on a 2d game, and i am making mountain. but I am have trouble in turing mountain from triangle to trapezium. I want some space on the top of mountain, but whatever I change, its not working or even get worth. I post the code down. (0,1) is dirt block, (5,10) is empty air block. also, if anyone could help me add something like fastnoiselite on the top of mountain that would be fantastic.

extends TileMapLayer

func _ready() → void:
randomize()

var x_value = 200 
var mountain_start = randi_range(50, x_value - 50) 
var mountain_width = randi_range(20, 40)  
var mountain_height = randi_range(10, 30)  
var flat_top_height = 3  

print("Mountain start:", mountain_start, "Width:", mountain_width, "Height:", mountain_height)

generate_full_mountain(mountain_start, mountain_width, mountain_height)

carve_mountain(mountain_start, mountain_width, mountain_height, flat_top_height)

func generate_full_mountain(start_x: int, width: int, height: int) → void:
for y_offset in range(height):
for x_offset in range(width):
set_cell(Vector2i(start_x + x_offset, 100 + y_offset), 0, Vector2i(0, 1), 0)

func carve_mountain(start_x: int, width: int, height: int, flat_top_height: int) → void:
for y_offset in range(height):
if y_offset > height - flat_top_height:
continue

	var layer_width = int(width * abs(sin((y_offset / float(height)) * PI / 2)))
	var left_bound = start_x + (width - layer_width) / 2 
	var right_bound = start_x + width - (width - layer_width) / 2 

	for x in range(start_x, start_x + width): 
		if x < left_bound or x > right_bound:
			set_cell(Vector2i(x, 100 + y_offset), 0, Vector2i(5, 10), 0)