credit.models
=============

.. py:module:: credit.models


Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/credit/models/base_model/index
   /autoapi/credit/models/camulator/index
   /autoapi/credit/models/checkpoint/index
   /autoapi/credit/models/crossformer/index
   /autoapi/credit/models/debugger_model/index
   /autoapi/credit/models/dscale_wrf/index
   /autoapi/credit/models/fuxi/index
   /autoapi/credit/models/graph/index
   /autoapi/credit/models/reset/index
   /autoapi/credit/models/swin/index
   /autoapi/credit/models/swin_wrf/index
   /autoapi/credit/models/unet/index
   /autoapi/credit/models/unet_attention_modules/index
   /autoapi/credit/models/unet_diffusion/index
   /autoapi/credit/models/unet_downscaling/index
   /autoapi/credit/models/wxformer/index


Attributes
----------

.. autoapisummary::

   credit.models.logger
   credit.models._MODEL_REGISTRY
   credit.models._CLASS_SOURCES


Functions
---------

.. autoapisummary::

   credit.models.__getattr__
   credit.models.register_model
   credit.models._load_model_entry
   credit.models.load_fsdp_or_checkpoint_policy
   credit.models.load_custom_model_modules
   credit.models.load_model
   credit.models.load_model_name


Package Contents
----------------

.. py:data:: logger

.. py:data:: _MODEL_REGISTRY

.. py:data:: _CLASS_SOURCES

.. py:function:: __getattr__(name)

.. py:function:: register_model(model_type, message=None)

   Decorator that adds an external PyTorch model class to the model registry.

   :param model_type: Key used in the config ``model.type`` field.
   :param message: Optional log message shown when the model is loaded.

   Example::

       @register_model("my_model", "Loading my custom model ...")
       class MyModel(torch.nn.Module):
           ...


.. py:function:: _load_model_entry(model_type)

   Lazily import and return (model_class, log_message) for a registered model type.


.. py:function:: load_fsdp_or_checkpoint_policy(conf)

.. py:function:: load_custom_model_modules(conf)

   Import every file listed under ``custom_models`` in the config.

   Each file is executed as a standalone module.  The expected use-case is
   that each file contains one or more classes decorated with
   ``@register_model``, so the import triggers registration as a side-effect.

   :param conf: Top-level config dict.  If ``custom_models`` is absent or
                empty this function is a no-op.
   :type conf: dict

   :raises FileNotFoundError: If a listed path does not exist on disk.


.. py:function:: load_model(conf, load_weights=False, model_name=False)

.. py:function:: load_model_name(conf, model_name, load_weights=False)

