class_docstr: A holder where one can register an abstract impl to.
class_docstr_tok: ["A","holder","where","one","can","register","an","abstract","impl","to","."]
docstr: Register an abstract impl.
  
  Returns a RegistrationHandle that one can use to de-register this
  abstract impl.
docstr_tok: ["Register","an","abstract","impl",".","Returns","a","RegistrationHandle","that","one","can","use","to","de-register","this","abstract","impl","."]
code: def register(self, func: Callable, source: str) -> RegistrationHandle:
      """Register an abstract impl.
  
      Returns a RegistrationHandle that one can use to de-register this
      abstract impl.
      """
      if self.kernel is not None:
          raise RuntimeError(
              f"impl_abstract(...): the operator {self.qualname} "
              f"already has an abstract impl registered at "
              f"{self.kernel.source}."
          )
      if torch._C._dispatch_has_kernel_for_dispatch_key(
          self.qualname, "Meta"
      ):
          raise RuntimeError(
              f"impl_abstract(...): the operator {self.qualname} "
              f"already has an DispatchKey::Meta implementation via a "
              f"pre-existing torch.library or TORCH_LIBRARY registration. "
              f"Please either remove that registration or don't call "
              f"impl_abstract."
          )
  
      if torch._C._dispatch_has_kernel_for_dispatch_key(
          self.qualname, "CompositeImplicitAutograd"
      ):
          raise RuntimeError(
              f"impl_abstract(...): the operator {self.qualname} "
              f"already has an implementation for this device type via a "
              f"pre-existing registration to "
              f"DispatchKey::CompositeImplicitAutograd."
              f"CompositeImplicitAutograd operators do not need an abstract "
              f"impl; "
              f"instead, the operator will decompose into its constituents "
              f"and those "
              f"can have abstract impls defined on them."
          )
  
      # Store the kernel in this holder
      self.kernel = Kernel(func, source)
  
      # Also register the abstract impl to Meta key
      if self.lib is None:
          ns = self.qualname.split("::")[0]
          self.lib = torch.library.Library(ns, "FRAGMENT")
      meta_kernel = construct_meta_kernel(self.qualname, self)
      self.lib.impl(self.qualname, meta_kernel, "Meta")
  
      def deregister_abstract_impl():
          if self.lib:
              self.lib._destroy()
              self.lib = None
          self.kernel = None
  
      return RegistrationHandle(deregister_abstract_impl)
  
file_path: pytorch/torch/_library/abstract_impl.py
imports: import contextlib
  import functools
  import warnings
  from typing import Callable, Optional
  import torch
  from torch._library.utils import Kernel, RegistrationHandle
label_desc: Use image node_id 2 for calling the AbstractImplHolder obj's underlying member method code with example usage: obj.register(func, source) and returns: RegistrationHandle