code: def construct_functional_impl(mutable_op):
      def functional_impl(*args):
          # Strategy:
          # - clone args that would have been mutated
          # - run mutable_op
          # - return the cloned args as additional outputs
          new_args = []
          extra_rets = []
          for is_write, arg in zip(mutable_args(mutable_op), args):
              if is_write:
                  cloned = arg.clone() if arg is not None else None
                  new_args.append(cloned)
                  extra_rets.append(cloned)
              else:
                  new_args.append(arg)
          result = mutable_op(*new_args)
          if result is None:
              return tuple(extra_rets)
          if isinstance(result, tuple):
              return (*result, *extra_rets)
          return (result, *extra_rets)
  
      return functional_impl
  
file_path: pytorch/torch/_custom_op/functional.py
imports: import weakref
  import torch
  import torch.utils._pytree
  from torch._C import _ExcludeDispatchKeyGuard, DispatchKey, DispatchKeySet
  from torch._ops import OpOverload
  from torch.library import Library
  from torchgen.model import BaseTy, BaseType, FunctionSchema, OperatorName, OptionalType, SchemaKind
  from .autograd import autograd_not_implemented
label_desc: Use image node_id 2 for calling a global function with example usage: construct_functional_impl(mutable_op) and returns: functional_impl, result,  unknown, tuple, unknown,  unknown