code: def define(qualname, schema, *, lib=None, tags=()):
      r"""Defines a new operator.
  
      In PyTorch, defining an op (short for "operator") is a two step-process:
      - we need to define the op (by providing an operator name and schema)
      - we need to implement behavior for how the operator interacts with
      various PyTorch subsystems, like CPU/CUDA Tensors, Autograd, etc.
  
      This entrypoint defines the custom operator (the first step)
      you must then perform the second step by calling various
      ``impl_*`` APIs, like :func:`torch.library.impl` or
      :func:`torch.library.impl_abstract`.
  
      Args:
          qualname (str): The qualified name for the operator. Should be
              a string that looks like "namespace::name", e.g. "aten::sin".
              Operators in PyTorch need a namespace to
              avoid name collisions; a given operator may only be created once.
              If you are writing a Python library, we recommend the namespace to
              be the name of your top-level module.
          schema (str): The schema of the operator. E.g. "(Tensor x) -> Tensor"
              for an op that accepts one Tensor and returns one Tensor. It does
              not contain the operator name (that is passed in ``qualname``).
          lib (Optional[Library]): If provided, the lifetime of this operator
              will be tied to the lifetime of the Library object.
          tags (Tag | Sequence[Tag]): one or more torch.Tag to apply to this
              operator. Tagging an operator changes the operator's behavior
              under various PyTorch subsystems; please read the docs for the
              torch.Tag carefully before applying it.
  
      Example::
          >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_LIBRARY)
          >>> import torch
          >>> import numpy as np
          >>>
          >>> # Define the operator
          >>> torch.library.define("mylib::sin", "(Tensor x) -> Tensor")
          >>>
          >>> # Add implementations for the operator
          >>> @torch.library.impl("mylibrary::sin", "cpu")
          >>> def f(x):
          >>>     return torch.from_numpy(np.sin(x.numpy()))
          >>>
          >>> # Call the new operator from torch.ops.
          >>> x = torch.randn(3)
          >>> y = torch.ops.mylib.sin(x)
          >>> assert torch.allclose(y, x)
  
      """
      if not isinstance(qualname, str):
          raise ValueError(
              f"define(qualname, schema): expected qualname "
              f"to be instance of str, got {type(qualname)}"
          )
      namespace, name = torch._library.utils.parse_namespace(qualname)
      if lib is None:
          lib = Library(namespace, "FRAGMENT")
          _keep_alive.append(lib)
      if not NAMELESS_SCHEMA.fullmatch(schema):
          raise ValueError(
              f"define(qualname, schema, ...): expected schema "
              f'to look like e.g. "(Tensor x) -> Tensor" but '
              f'got "{schema}"'
          )
      lib.define(name + schema, alias_analysis="", tags=tags)
  
imports: from ._ops import OpOverload
  from typing import Any, Optional, Set, List
  import traceback
  import torch
  import weakref
  import functools
  import inspect
  import re
  import sys
label_desc: Use image node_id 3 for calling a global function with example usage: define(qualname, schema) without return types