from typing import Type
import inspect


def get_ncluster_kwarg(cls: Type) -> str:
    """Get the kwarg of `cls.__init__()` that corresponds to the number of clusters.

    Args:
        cls (Type): Estimator class.

    Returns:
        str: "n_clusters", "n_components" (for GMM), or "".
    """
    kwargs = inspect.signature(cls).parameters
    if "n_clusters" in kwargs:
        return "n_clusters"
    elif "n_components" in kwargs:
        return "n_components"
    else:
        return ""