om a UNet:   Copied if args.controlnet_model_name_or_path:
    logger.info("Loading existing controlnet weights")
    controlnet = ControlNetModel.from_pretrained(args.controlnet_model_name_or_path)
else:
    logger.info("Initializing controlnet weights from unet")
    controlnet = ControlNetModel.from_unet(unet) The optimizer is set up to update the ControlNet parameters:   Copied params_to_optimize = controlnet.parameters()
optimizer = optimi