code: def register_pattern(
      name: str,
      pattern_factory: Callable[[AnyStr], Pattern],
      override: Optional[bool] = None,
  ) -> None:
      """
      Registers the specified pattern factory.
  
      *name* (:class:`str`) is the name to register the pattern factory
      under.
  
      *pattern_factory* (:class:`~collections.abc.Callable`) is used to
      compile patterns. It must accept an uncompiled pattern (:class:`str`)
      and return the compiled pattern (:class:`.Pattern`).
  
      *override* (:class:`bool` or :data:`None`) optionally is whether to
      allow overriding an already registered pattern under the same name
      (:data:`True`), instead of raising an :exc:`AlreadyRegisteredError`
      (:data:`False`). Default is :data:`None` for :data:`False`.
      """
      if not isinstance(name, str):
          raise TypeError(f"name:{name!r} is not a string.")
  
      if not callable(pattern_factory):
          raise TypeError(
              f"pattern_factory:{pattern_factory!r} is not callable."
          )
  
      if name in _registered_patterns and not override:
          raise AlreadyRegisteredError(name, _registered_patterns[name])
  
      _registered_patterns[name] = pattern_factory
  
imports: import os
  import os.path
  import pathlib
  import posixpath
  import stat
  import sys
  import warnings
  from collections.abc import Collection, Iterable
  from dataclasses import dataclass
  from os import PathLike
  from typing import Any, AnyStr, Callable, Collection, Dict, Generic, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, TypeVar, Union
  from .pattern import Pattern
label_desc: Use image node_id 15 for calling a global function with example usage: register_pattern(name, pattern_factory, override) without return types