code: def backwards_not_supported(prim):
      def redispatch_prim(args, kwargs):
          with torch._C._AutoDispatchBelowAutograd():
              old = torch._C._dispatch_tls_is_dispatch_key_excluded(
                  torch._C.DispatchKey.ADInplaceOrView
              )
              return prim(*args, **kwargs)
  
      class BackwardsNotSupported(torch.autograd.Function):
          @staticmethod
          def forward(ctx, args_spec, *flat_args):
              args, kwargs = tree_unflatten(flat_args, args_spec)  # type: ignore[arg-type]
              return redispatch_prim(args, kwargs)
  
          @staticmethod
          def backward(ctx, *args):
              raise RuntimeError("backwards not supported on prim")
  
      @wraps(prim)
      def _autograd_impl(*args, **kwargs):
          flat_args, args_spec = tree_flatten((args, kwargs))
          if torch.is_grad_enabled() and any(
              a.requires_grad
              for a in flat_args
              if isinstance(a, torch.Tensor)
          ):
              # TODO: There is a subtle bug here: prims like copy_to
              # return their input argument after mutating it; and custom
              # autograd function will incorrectly turn the result into
              # a view which will fail test_python_ref_executor tests.
              # At the moment, we sidestep this by observing that the
              # unit tests don't ever try to run the executor with
              # autograd, so we don't exercise the buggy case, but if
              # you ever want to feed autograd through this, be aware
              # of it!  We need a way of properly implementing autograd
              # for mutating operations in Python to do this.
              return BackwardsNotSupported.apply(args_spec, *flat_args)
          else:
              return redispatch_prim(args, kwargs)
  
      return _autograd_impl
  
imports: import inspect
  import warnings
  from functools import wraps
  from itertools import chain
  from typing import Callable, NamedTuple, Optional, overload, Sequence, Tuple
  import torch
  import torch._prims_common
  from torch._prims_common import CustomOutParamAnnotation, ELEMENTWISE_TYPE_PROMOTION_KIND, Number, NumberType, ShapeType, TensorLike, TensorLikeType
  from torch.utils import _pytree
  from torch.utils._pytree import tree_flatten, tree_unflatten
label_desc: Use image node_id 13 for calling a global function with example usage: backwards_not_supported(prim) and returns: _autograd_impl, prim, redispatch_prim, BackwardsNotSupported, redispatch_prim