code: def optimize_model(model, passes):
      """Optimize a given model with the given passes.
  
      The passes are attempted until all passes no longer match or no changes to the model graph occur.
  
      Args:
          model (ModelGraph): The model to optimize.
          passes (list): List of passes to apply.
  
      Returns:
          set: The set of applied passes (the passes that matched the predicate).
      """
      optimizers = {
          opt_pass: get_optimizer(opt_pass) for opt_pass in passes
      }
      applied_passes = set()
      optimization_done = False
      while not optimization_done:
          for opt_name, opt in optimizers.items():
              if (
                  isinstance(opt, ModelOptimizerPass)
                  and opt_name not in applied_passes
              ):
                  res = opt.transform(model)
                  if res:
                      applied_passes.add(opt_name)
                  continue
              for node in model.graph.values():
                  if opt.match(node):
                      res = opt.transform(model, node)
                      applied_passes.add(opt_name)
                      if res:
                          break
              else:
                  continue
              break
          else:
              optimization_done = True
  
      return applied_passes
  
imports: import importlib
  import inspect
  import os
  from hls4ml.utils.string_utils import convert_to_snake_case
label_desc: Use image node_id 11 for calling a global function with example usage: optimize_model(model, passes) and returns: applied_passes