message: Use OpDef to determine unique shared_name.
  There are NodeDefs (for example from loaded saved models) that do not
  specify shared_name for ops that have them.
diff: @@ -26,6 +26,7 @@ from tensorflow.python.eager import def_function
  from tensorflow.python.eager import function as function_lib
  from tensorflow.python.framework import func_graph as func_graph_lib
  from tensorflow.python.framework import function_def_to_graph as function_def_lib
  +from tensorflow.python.framework import op_def_registry
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import type_spec
  @@ -410,14 +411,21 @@ def fix_node_def(node_def, functions, shared_name_suffix, debug_name):
  # TODO(b/124205571): Avoid accidental sharing and destruction of restored
  # resources. For now uniquify "shared_name" when loading functions to avoid
  # sharing.
  - if "shared_name" in node_def.attr:
  - if node_def.attr["shared_name"].s:
  - node_def.attr["shared_name"].s += compat.as_bytes(shared_name_suffix)
  - else:
  - # Blank shared_name attributes would use the node name, so we'll start
  - # with that when uniquifying.
  + # TODO: Add regression test for b/150826922.
  + op_def = op_def_registry.get(node_def.op)
  + if op_def:
  + attr = next((a for a in op_def.attr if a.name == "shared_name"), None)
  + if attr:
  + shared_name = None
  + if "shared_name" in node_def.attr and node_def.attr["shared_name"].s:
  + shared_name = node_def.attr["shared_name"].s
  + elif attr.default_value.s:
  + shared_name = compat.as_bytes(attr.default_value.s)
  + if not shared_name:
  + shared_name = compat.as_bytes(node_def.name)
  +
  node_def.attr["shared_name"].s = (
  - compat.as_bytes(node_def.name) + compat.as_bytes(shared_name_suffix))
  + shared_name + compat.as_bytes(shared_name_suffix))
  def _fix_fdef(orig_fdef, functions, shared_name_suffix):
  