code: def register_model(fn):
      # 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]
  
      # add entries to registry dict/sets
      _model_entrypoints[model_name] = fn
      _model_to_module[model_name] = module_name
      _module_to_models[module_name].add(model_name)
      has_valid_pretrained = False  # check if model has a pretrained url to allow filtering on this
      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
          cfg = mod.default_cfgs[model_name]
          has_valid_pretrained = (
              ("url" in cfg and "http" in cfg["url"])
              or ("file" in cfg and cfg["file"])
              or ("hf_hub_id" in cfg and cfg["hf_hub_id"])
          )
          _model_pretrained_cfgs[model_name] = mod.default_cfgs[
              model_name
          ]
      if has_valid_pretrained:
          _model_has_pretrained.add(model_name)
      return fn
  
file_path: generalized-moe/domainbed/registry.py
imports: import sys
  import re
  import fnmatch
  from collections import defaultdict
  from copy import deepcopy
label_desc: Use image node_id 1 for calling a global function with example usage: register_model(fn) and returns: fn