"""按配置构建模型。""" from __future__ import annotations from collections.abc import Mapping from typing import Any from torch import nn from models.registry import MODELS def build_model(cfg: Mapping[str, Any]) -> nn.Module: """`cfg` 至少包含 `name` 与 `num_classes`,其余透传给模型构造函数。""" return MODELS.build(dict(cfg))