def METHOD_NAME(model, graph, excludes):
  excluded_nodes = []
  module_to_node = map_original_module_to_node(model, graph)
  for exclude in excludes:
    if isinstance(exclude, str):
      excluded_nodes.append(exclude)
    elif isinstance(exclude, torch.nn.Module):
      for module in exclude.modules():
        module_id = id(module)
        if module_id in module_to_node:
          excluded_nodes.append(module_to_node[module_id])
    else:
      raise errors.OptimizerInvalidArgumentError(
          'Excludes must be either string or torch.nn.Module')
  return excluded_nodes