code: def register_model(fn: Callable[..., Any]) -> Callable[..., Any]:
      # lookup containing module
      mod = sys.modules[fn.__module__]
      module_name_split = fn.__module__.split(".")
      module_name = (
          module_name_split[-1] if len(module_name_split) else ""
      )
  
      # add model to __all__ in module
      model_name = fn.__name__
      if hasattr(mod, "__all__"):
          mod.__all__.append(model_name)
      else:
          mod.__all__ = [model_name]  # type: ignore
  
      # add entries to registry dict/sets
      if model_name in _model_entrypoints:
          warnings.warn(
              f"Overwriting {model_name} in registry with {fn.__module__}.{model_name}. This is because the name being "
              "registered conflicts with an existing name. Please check if this is not expected.",
              stacklevel=2,
          )
      _model_entrypoints[model_name] = fn
      _model_to_module[model_name] = module_name
      _module_to_models[module_name].add(model_name)
      if (
          hasattr(mod, "default_cfgs")
          and model_name in mod.default_cfgs
      ):
          # this will catch all models that have entrypoint matching cfg key, but miss any aliasing
          # entrypoints or non-matching combos
          default_cfg = mod.default_cfgs[model_name]
          if not isinstance(default_cfg, DefaultCfg):
              # new style default cfg dataclass w/ multiple entries per model-arch
              assert isinstance(default_cfg, dict)
              # old style cfg dict per model-arch
              pretrained_cfg = PretrainedCfg(**default_cfg)
              default_cfg = DefaultCfg(
                  tags=deque([""]), cfgs={"": pretrained_cfg}
              )
  
          for tag_idx, tag in enumerate(default_cfg.tags):
              is_default = tag_idx == 0
              pretrained_cfg = default_cfg.cfgs[tag]
              model_name_tag = (
                  ".".join([model_name, tag]) if tag else model_name
              )
              replace_items = dict(
                  architecture=model_name, tag=tag if tag else None
              )
              if (
                  pretrained_cfg.hf_hub_id
                  and pretrained_cfg.hf_hub_id == "timm/"
              ):
                  # auto-complete hub name w/ architecture.tag
                  replace_items["hf_hub_id"] = (
                      pretrained_cfg.hf_hub_id + model_name_tag
                  )
              pretrained_cfg = replace(pretrained_cfg, **replace_items)
  
              if is_default:
                  _model_pretrained_cfgs[model_name] = pretrained_cfg
                  if pretrained_cfg.has_weights:
                      # add tagless entry if it's default and has weights
                      _model_has_pretrained.add(model_name)
  
              if tag:
                  _model_pretrained_cfgs[
                      model_name_tag
                  ] = pretrained_cfg
                  if pretrained_cfg.has_weights:
                      # add model w/ tag if tag is valid
                      _model_has_pretrained.add(model_name_tag)
                  _model_with_tags[model_name].append(model_name_tag)
              else:
                  _model_with_tags[model_name].append(
                      model_name
                  )  # has empty tag (to slowly remove these instances)
  
          _model_default_cfgs[model_name] = default_cfg
  
      return fn
  
imports: import fnmatch
  import re
  import sys
  import warnings
  from collections import defaultdict, deque
  from copy import deepcopy
  from dataclasses import replace
  from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Sequence, Union, Tuple
  from ._pretrained import PretrainedCfg, DefaultCfg
label_desc: Use image node_id 4 for calling a global function with example usage: register_model(fn) and returns: fn