code: def define_function_signature(name, docstring, signature):
      """A decorator which sets the name, signature and docstring of the function
      passed into it."""
      if name == "<lambda>":
          name = "_lambda_"
      check_valid_identifier(name)
      for a in signature.parameters:
          check_valid_identifier(a)
  
      used_names = {*signature.parameters, name}
  
      newsig = signature.replace(
          parameters=[
              p
              if p.default is signature.empty
              else p.replace(default=not_set)
              for p in (
                  p.replace(annotation=signature.empty)
                  for p in signature.parameters.values()
              )
          ],
          return_annotation=signature.empty,
      )
  
      pos_args = [
          p
          for p in signature.parameters.values()
          if p.kind.name.startswith("POSITIONAL_")
      ]
  
      def accept(f):
          fsig = inspect.signature(f, follow_wrapped=False)
          must_pass_as_kwargs = []
          invocation_parts = []
          for p in pos_args:
              if (
                  p.name not in fsig.parameters
                  and get_varargs(fsig) is None
              ):
                  must_pass_as_kwargs.append(p.name)
              else:
                  invocation_parts.append(p.name)
          if get_varargs(signature) is not None:
              invocation_parts.append("*" + get_varargs(signature).name)
          for k in must_pass_as_kwargs:
              invocation_parts.append(f"{k}={k}")
          for p in signature.parameters.values():
              if p.kind is p.KEYWORD_ONLY:
                  invocation_parts.append(f"{p.name}={p.name}")
          varkw = get_varargs(
              signature, kind=inspect.Parameter.VAR_KEYWORD
          )
          if varkw:
              invocation_parts.append("**" + varkw.name)
  
          candidate_names = ["f"] + [
              f"f_{i}" for i in range(1, len(used_names) + 2)
          ]
  
          for funcname in candidate_names:  # pragma: no branch
              if funcname not in used_names:
                  break
  
          source = COPY_SIGNATURE_SCRIPT.format(
              name=name,
              funcname=funcname,
              signature=str(newsig),
              invocation=", ".join(invocation_parts),
          )
          result = source_exec_as_module(source).accept(f)
          result.__doc__ = docstring
          result.__defaults__ = tuple(
              p.default
              for p in signature.parameters.values()
              if p.default is not signature.empty
              and "POSITIONAL" in p.kind.name
          )
          kwdefaults = {
              p.name: p.default
              for p in signature.parameters.values()
              if p.default is not signature.empty
              and p.kind is p.KEYWORD_ONLY
          }
          if kwdefaults:
              result.__kwdefaults__ = kwdefaults
          annotations = {
              p.name: p.annotation
              for p in signature.parameters.values()
              if p.annotation is not signature.empty
          }
          if signature.return_annotation is not signature.empty:
              annotations["return"] = signature.return_annotation
          if annotations:
              result.__annotations__ = annotations
          return result
  
      return accept
  
imports: import ast
  import hashlib
  import inspect
  import os
  import re
  import sys
  import textwrap
  import types
  from functools import wraps
  from io import StringIO
  from keyword import iskeyword
  from tokenize import COMMENT, detect_encoding, generate_tokens, untokenize
  from types import ModuleType
  from typing import TYPE_CHECKING, Any, Callable
  from unittest.mock import _patch
  from hypothesis.internal.compat import PYPY, is_typed_named_tuple
  from hypothesis.utils.conventions import not_set
  from hypothesis.vendor.pretty import pretty
label_desc: Use image node_id 20 for calling a global function with example usage: define_function_signature(name, docstring, signature) and returns: accept, result