def create(
        cls,
        *,
        qid_shape: tuple[int, ...],
        grouping: dict[int, int],
        initial_state: int = 0,
        simulation_options: MPSOptions = MPSOptions(),
    ):
        """Creates an MPSQuantumState

        Args:
            qid_shape: Dimensions of the qubits represented.
            grouping: How to group qubits together, if None all are individual.
            initial_state: The initial computational basis state.
            simulation_options: Numerical options for the simulation.

        Raises:
            ValueError: If the grouping does not cover the qubits.
        """
        M = []
        for _ in range(max(grouping.values()) + 1):
            M.append(qtn.Tensor())

        # The order of the qubits matters, because the state |01> is different from |10>. Since
        # Quimb uses strings to name tensor indices, we want to be able to sort them too. If we are
        # working with, say, 123 qubits then we want qubit 3 to come before qubit 100, but then
        # we want write the string '003' which comes before '100' in lexicographic order. The code
        # below is just simple string formatting.
        max_num_digits = len(f'{max(grouping.values())}')
        format_i = f'i_{{:0{max_num_digits}}}'

        # TODO(tonybruguier): Instead of relying on sortable indices could you keep a parallel
        # mapping of e.g. qubit to string-index and do all "logic" on the qubits themselves and
        # only translate to string-indices when calling a quimb API.

        # TODO(tonybruguier): Refactor out so that the code below can also be used by
        # circuit_to_tensors in cirq.contrib.quimb.state_vector.

        for axis in reversed(range(len(qid_shape))):
            d = qid_shape[axis]
            x = np.zeros(d)
            x[initial_state % d] = 1.0

            n = grouping[axis]
            M[n] @= qtn.Tensor(x, inds=(format_i.format(axis),))
            initial_state = initial_state // d
        return _MPSHandler(
            qid_shape=qid_shape,
            grouping=grouping,
            M=M,
            format_i=format_i,
            estimated_gate_error_list=[],
            simulation_options=simulation_options,
        )
Creates an MPSQuantumState

        Args:
            qid_shape: Dimensions of the qubits represented.
            grouping: How to group qubits together, if None all are individual.
            initial_state: The initial computational basis state.
            simulation_options: Numerical options for the simulation.

        Raises:
            ValueError: If the grouping does not cover the qubits.
        
cirq-core/cirq/contrib/quimb/mps_simulator.py