def __new__(cls, name: str, dimension: int) -> cirq.NamedQid:
        """Initializes a `NamedQid` with a given name and dimension.

        Args:
            name: The name.
            dimension: The dimension of the qid's Hilbert space, i.e.
                the number of quantum levels.
        """
        key = (name, dimension)
        inst = cls._cache.get(key)
        if inst is None:
            cls.validate_dimension(dimension)
            inst = super().__new__(cls)
            inst._name = name
            inst._dimension = dimension
            cls._cache[key] = inst
        return inst
Initializes a `NamedQid` with a given name and dimension.

        Args:
            name: The name.
            dimension: The dimension of the qid's Hilbert space, i.e.
                the number of quantum levels.
        
cirq-core/cirq/ops/named_qubit.py