def METHOD_NAME(
    dims: int | tuple,
    rank: int | None = None,
    method: Literal["Hilbert-Schmidt", "Bures"] = "Hilbert-Schmidt",
    seed: int | np.random.Generator | None = None,
) -> DensityMatrix:
    """Generator a random DensityMatrix.
    Args:
        dims (int or tuple): the dimensions of the DensityMatrix.
        rank (int or None): Optional, the rank of the density matrix.
                            The default value is full-rank.
        method (string): Optional. The method to use.
            'Hilbert-Schmidt': (Default) sample from the Hilbert-Schmidt metric.
            'Bures': sample from the Bures metric.
        seed (int or np.random.Generator): Optional. Set a fixed seed or
                                           generator for RNG.
    Returns:
        DensityMatrix: the random density matrix.
    Raises:
        QiskitError: if the method is not valid.
    """
    # Flatten dimensions
    dim = np.prod(dims)
    if rank is None:
        rank = dim  # Use full rank
    if method == "Hilbert-Schmidt":
        rho = _random_density_hs(dim, rank, seed)
    elif method == "Bures":
        rho = _random_density_bures(dim, rank, seed)
    else:
        raise QiskitError(f"Error: unrecognized method {method}")
    return DensityMatrix(rho, dims=dims)