Removing last layer from yolov8 pretrained model

I have a pretrained model and i want to remove the last layer of it and convert to tflite model . This is the yaml file ultralytics/yolov8.yaml at main · ultralytics/ultralytics · GitHub . i tried by using

model = YOLO("path to pretrained model")
model = torch.nn.Sequential(*list(model1.model.children())[:-1])

but it seems that that is not correct method . Is there any way by changing in yolov8.yaml file and removing the last layer and then converting to tflite.