code: def define_function_signature(name, docstring, argspec):
      """A decorator which sets the name, argspec and docstring of the function
      passed into it."""
      check_valid_identifier(name)
      for a in argspec.args:
          check_valid_identifier(a)
      if argspec.varargs is not None:
          check_valid_identifier(argspec.varargs)
      if argspec.varkw is not None:
          check_valid_identifier(argspec.varkw)
      n_defaults = len(argspec.defaults or ())
      if n_defaults:
          parts = []
          for a in argspec.args[:-n_defaults]:
              parts.append(a)
          for a in argspec.args[-n_defaults:]:
              parts.append("%s=not_set" % (a,))
      else:
          parts = list(argspec.args)
      used_names = list(argspec.args) + list(argspec.kwonlyargs)
      used_names.append(name)
  
      for a in argspec.kwonlyargs:
          check_valid_identifier(a)
  
      def accept(f):
          fargspec = getfullargspec(f)
          must_pass_as_kwargs = []
          invocation_parts = []
          for a in argspec.args:
              if a not in fargspec.args and not fargspec.varargs:
                  must_pass_as_kwargs.append(a)
              else:
                  invocation_parts.append(a)
          if argspec.varargs:
              used_names.append(argspec.varargs)
              parts.append("*" + argspec.varargs)
              invocation_parts.append("*" + argspec.varargs)
          elif argspec.kwonlyargs:
              parts.append("*")
          for k in must_pass_as_kwargs:
              invocation_parts.append("%(k)s=%(k)s" % {"k": k})
  
          for k in argspec.kwonlyargs:
              invocation_parts.append("%(k)s=%(k)s" % {"k": k})
              if k in (argspec.kwonlydefaults or []):
                  parts.append("%(k)s=not_set" % {"k": k})
              else:
                  parts.append(k)
          if argspec.varkw:
              used_names.append(argspec.varkw)
              parts.append("**" + argspec.varkw)
              invocation_parts.append("**" + argspec.varkw)
  
          candidate_names = ["f"] + [
              "f_%d" % (i,) for i in hrange(1, len(used_names) + 2)
          ]
  
          for funcname in candidate_names:  # pragma: no branch
              if funcname not in used_names:
                  break
  
          base_accept = source_exec_as_module(
              COPY_ARGSPEC_SCRIPT
              % {
                  "name": name,
                  "funcname": funcname,
                  "argspec": ", ".join(parts),
                  "invocation": ", ".join(invocation_parts),
              }
          ).accept
  
          result = base_accept(f)
          result.__doc__ = docstring
          result.__defaults__ = argspec.defaults
          if argspec.kwonlydefaults:
              result.__kwdefaults__ = argspec.kwonlydefaults
          if argspec.annotations:
              result.__annotations__ = argspec.annotations
          return result
  
      return accept
  
imports: from __future__ import absolute_import, division, print_function
  import ast
  import hashlib
  import inspect
  import re
  import types
  from functools import wraps
  from types import ModuleType
  from hypothesis.internal.compat import ARG_NAME_ATTRIBUTE, PY2, getfullargspec, hrange, isidentifier, qualname, str_to_bytes, to_str, to_unicode, update_code_location
  from hypothesis.vendor.pretty import pretty
label_desc: Use image node_id 17 for calling a global function with example usage: define_function_signature(name, docstring, argspec) and returns: accept, result