def from_diagram(diagram: str, dimension: int) -> list[GridQid]:
        """Parse ASCII art device layout into a device.

        As an example, the below diagram will create a list of GridQid in a
        pyramid structure.


        ```
        ---A---
        --AAA--
        -AAAAA-
        AAAAAAA
        ```

        You can use any character other than a hyphen, period or space to mark a
        qid. As an example, the qids for a Bristlecone device could be
        represented by the below diagram. This produces a diamond-shaped grid of
        qids, and qids with the same letter correspond to the same readout line.

        ```
        .....AB.....
        ....ABCD....
        ...ABCDEF...
        ..ABCDEFGH..
        .ABCDEFGHIJ.
        ABCDEFGHIJKL
        .CDEFGHIJKL.
        ..EFGHIJKL..
        ...GHIJKL...
        ....IJKL....
        .....KL.....
        ```

        Args:
            diagram: String representing the qid layout. Each line represents
                a row. Alphanumeric characters are assigned as qid.
                Dots ('.'), dashes ('-'), and spaces (' ') are treated as
                empty locations in the grid. If diagram has characters other
                than alphanumerics, spacers, and newlines ('\\n'), an error will
                be thrown. The top-left corner of the diagram will be have
                coordinate (0, 0).

            dimension: The dimension of the qubits in the `cirq.GridQid`s used
                in this construction.

        Returns:
            A list of `cirq.GridQid`s corresponding to qids in the provided diagram

        Raises:
            ValueError: If the input string contains an invalid character.
        """
        coords = _ascii_diagram_to_coords(diagram)
        return [GridQid(*c, dimension=dimension) for c in coords]
Parse ASCII art device layout into a device.

        As an example, the below diagram will create a list of GridQid in a
        pyramid structure.


        ```
        ---A---
        --AAA--
        -AAAAA-
        AAAAAAA
        ```

        You can use any character other than a hyphen, period or space to mark a
        qid. As an example, the qids for a Bristlecone device could be
        represented by the below diagram. This produces a diamond-shaped grid of
        qids, and qids with the same letter correspond to the same readout line.

        ```
        .....AB.....
        ....ABCD....
        ...ABCDEF...
        ..ABCDEFGH..
        .ABCDEFGHIJ.
        ABCDEFGHIJKL
        .CDEFGHIJKL.
        ..EFGHIJKL..
        ...GHIJKL...
        ....IJKL....
        .....KL.....
        ```

        Args:
            diagram: String representing the qid layout. Each line represents
                a row. Alphanumeric characters are assigned as qid.
                Dots ('.'), dashes ('-'), and spaces (' ') are treated as
                empty locations in the grid. If diagram has characters other
                than alphanumerics, spacers, and newlines ('\n'), an error will
                be thrown. The top-left corner of the diagram will be have
                coordinate (0, 0).

            dimension: The dimension of the qubits in the `cirq.GridQid`s used
                in this construction.

        Returns:
            A list of `cirq.GridQid`s corresponding to qids in the provided diagram

        Raises:
            ValueError: If the input string contains an invalid character.
        
cirq-core/cirq/devices/grid_qubit.py