def random_convex_coord(names, select=None, temp=1):
    """
    corners: dict[dict[]]
    select: str | dict
    temp: float - like softmax, high temp = more even numbers, low temp = more 0s and 1s
    """

    if isinstance(temp, (float, int)):
        temp = temp * np.ones(len(names))
    elif isinstance(temp, dict):
        temp = np.array([temp[n] for n in names])
    elif isinstance(temp, np.ndarray):
        pass
    else:
        raise ValueError(f"Unrecognized {temp=}")

    if isinstance(select, str):
        if select not in names:
            raise ValueError(
                f"Attempted to random_convex_comb({names=}, {select=}) but select is invalid"
            )
        return {n: 1 if n == select else 0 for n in names}

    if isinstance(select, dict):
        if any(k not in names for k in select):
            raise ValueError(
                f"Attempted to random_convex_comb({names=}, {select.keys()=}) but select is invalid"
            )
        weights = select
        norm = sum(weights.values())
        for k, v in weights.items():
            weights[k] = v / norm
        return weights

    vs = np.random.dirichlet(temp)
    weights = {k: vs[i] for i, k in enumerate(names)}
    return weights

    corners: dict[dict[]]
    select: str | dict
    temp: float - like softmax, high temp = more even numbers, low temp = more 0s and 1s
    
infinigen/assets/objects/creatures/util/part_util.py