class_docstr: Class for custom operators in PyTorch.
  
  Use the CustomOp API to create user-defined custom operators that behave
  just like regular PyTorch operators (e.g. torch.sin, torch.mm) when it
  comes to various PyTorch subsystems (like torch.compile).
  
  To construct a `CustomOp`, use `custom_op`.
code: def _check_can_register_backward(self):
      def error(detail):
          raise RuntimeError(
              f"Cannot use torch._custom_ops APIs to register backward "
              f"formula for {detail}. Got operator "
              f"{self._qualname} with schema: {schema}"
          )
  
      schema = self._schema
      if schema.kind() != SchemaKind.functional:
          error("non-functional operator")
  
      rets = schema.returns
      if not schema.returns:
          error("operator with no returns")
  
      assert len(rets) > 0
      is_non_mutating_view = any(
          r.annotation is not None and not r.annotation.is_write
          for r in rets
      )
      if is_non_mutating_view:
          error("operator that returns views")
  
      # We make assumptions about the schema's return types.
      allowed_return_types = {
          BaseType(BaseTy.int): "int",
          BaseType(BaseTy.SymInt): "SymInt",
          BaseType(BaseTy.bool): "bool",
          BaseType(BaseTy.float): "float",
          BaseType(BaseTy.Tensor): "Tensor",
          ListType(BaseType(BaseTy.Tensor), None): "List[Tensor]",
      }
      for ret in schema.returns:
          if ret.type in allowed_return_types:
              continue
          error(
              f"operator with return not in {list(allowed_return_types.values())} (got {ret.type})"
          )
  
imports: import dataclasses
  import functools
  import inspect
  import sys
  import typing
  import weakref
  from torchgen.model import FunctionSchema, OperatorName, SchemaKind, BaseType, ListType, BaseTy
  import torch
  import torch._C
  import torch.library
  from torch._library.abstract_impl import AbstractImplCtx
  from torch.library import get_ctx
  from .autograd import autograd_kernel_indirection, construct_autograd_kernel
label_desc: Use image node_id 13 for calling the CustomOp obj's underlying member method code with example usage: obj._check_can_register_backward() without return types