def _raise_value_error_if_ambiguous(self) -> None:
        """Raise an error if the qid shape is ambiguous and cannot be inferred."""
        if self.min_qudit_dimensions is not None:
            raise ValueError(
                'Qid shape is ambiguous: '
                f'Could be any shape on {len(self.min_qudit_dimensions)} qudits '
                'with the corresponding qudit dimensions being at least '
                f'{self.min_qudit_dimensions}.'
            )
        if len(self.explicit_qid_shapes) > 1:  # pragma: no cover
            raise ValueError(
                f'Qid shape is ambiguous: Could be any one of {self.explicit_qid_shapes}.'
            )
        if self.explicit_qid_shapes and self.unfactorized_total_dimension is not None:
            explicit_shape = next(iter(self.explicit_qid_shapes))
            raise ValueError(
                'Qid shape is ambiguous: '
                f'Could be {explicit_shape} or any shape compatible with '
                f'a Hilbert space dimension of {self.unfactorized_total_dimension}.'
            )
Raise an error if the qid shape is ambiguous and cannot be inferred.
cirq-core/cirq/qis/states.py