from tensorflow.python.util import compat

        temp_graph, inputs, outputs, out_names=self._out_names)

    # Extra kwargs are treated as attrs on the function def.
    kwargs_attr = _parse_kwargs_as_attrs(**self._extra_kwargs)
    for k in kwargs_attr:
      self._definition.attr[k].CopyFrom(kwargs_attr[k])

    # Hash the definition and its dependencies.
    hasher = hashlib.sha1()

    def _hash_func_def():
      """Hash the function definition agnostic to node/map ordering."""

      def update_num(n):
        hasher.update(compat.as_bytes("%x" % n))

      def update_str(s):
        update_num(len(s))
        hasher.update(compat.as_bytes(s))

      def update_strs(slist):
        update_num(len(slist))
        for s in slist:
          update_str(s)

      for adef in self._definition.signature.input_arg:
        update_str(adef.SerializeToString())

