code: def delete_nodes_with_only_constant_descendents(tfssa):
      # look for nodes whose value is known AND downstream values are known
      # and delete them
      delete_count = 0
      for fn_key in list(tfssa.functions.keys()):
          f = tfssa.functions[fn_key]
          keys = list(f.graph.keys())
          for k in keys:
              if k not in f.graph:
                  continue
              to_delete = (f.graph[k].value is not None) and (
                  k not in f.outputs
              )
              if to_delete:
                  # check the outputs
                  for o in f.graph[k].outputs:
                      if f.graph[o].value is None:
                          to_delete = False
                      else:
                          disconnect_edge(f.graph, k, o)
              if to_delete:
                  delete_count += 1
                  delete_node(f.graph, k)
          # also delete all Const nodes with no descendants
          keys = list(f.graph.keys())
          for k in keys:
              if k not in f.graph:
                  continue
              if (
                  f.graph[k].op == "Const"
                  and len(f.graph[k].outputs) == 0
                  and (k not in f.outputs)
              ):
                  delete_count += 1
                  delete_node(f.graph, k)
      return delete_count
  
imports: from coremltools import _logger
  from ..basic_graph_ops import check_connections, delete_node, disconnect_edge
label_desc: Use image node_id 2 for calling a global function with example usage: delete_nodes_with_only_constant_descendents(tfssa) and returns: delete_count