def repeat(
        self,
        repetitions: IntParam | None = None,
        repetition_ids: Sequence[str] | None = None,
        use_repetition_ids: bool | None = None,
    ) -> CircuitOperation:
        """Returns a copy of this operation repeated 'repetitions' times.
         Each repetition instance will be identified by a single repetition_id.

        Args:
            repetitions: Number of times this operation should repeat. This
                is multiplied with any pre-existing repetitions. If unset, it
                defaults to the length of `repetition_ids`.
            repetition_ids: List of IDs, one for each repetition. If unset,
                defaults to `default_repetition_ids(repetitions)`.
            use_repetition_ids: If given, this specifies the value for `use_repetition_ids`
                of the resulting circuit operation. If not given, we enable ids if
                `repetition_ids` is not None, and otherwise fall back to
                `self.use_repetition_ids`.

        Returns:
            A copy of this operation repeated `repetitions` times with the
            appropriate `repetition_ids`. The output `repetition_ids` are the
            cartesian product of input `repetition_ids` with the base
            operation's `repetition_ids`. If the base operation has unset
            `repetition_ids` (indicates {-1, 0, 1} `repetitions` with no custom
            IDs), the input `repetition_ids` are directly used.

        Raises:
            TypeError: `repetitions` is not an integer value.
            ValueError: Unexpected length of `repetition_ids`.
            ValueError: Both `repetitions` and `repetition_ids` are None.
        """
        if use_repetition_ids is None:
            use_repetition_ids = True if repetition_ids is not None else self.use_repetition_ids

        if repetitions is None:
            if repetition_ids is None:
                raise ValueError('At least one of repetitions and repetition_ids must be set')
            repetitions = len(repetition_ids)

        if isinstance(repetitions, INT_CLASSES):
            if repetitions == 1 and repetition_ids is None:
                # As CircuitOperation is immutable, this can safely return the original.
                return self

            expected_repetition_id_length: int = np.abs(repetitions)

            if repetition_ids is None:
                if use_repetition_ids:
                    repetition_ids = default_repetition_ids(expected_repetition_id_length)
            elif len(repetition_ids) != expected_repetition_id_length:
                raise ValueError(
                    f'Expected repetition_ids={repetition_ids} length to be '
                    f'{expected_repetition_id_length}'
                )

        # If either self.repetition_ids or repetitions is None, it returns the other unchanged.
        repetition_ids = _full_join_string_lists(repetition_ids, self.repetition_ids)

        # The eventual number of repetitions of the returned CircuitOperation.
        final_repetitions = protocols.mul(self.repetitions, repetitions)
        return self.replace(
            repetitions=final_repetitions,
            repetition_ids=repetition_ids,
            use_repetition_ids=use_repetition_ids,
        )
Returns a copy of this operation repeated 'repetitions' times.
         Each repetition instance will be identified by a single repetition_id.

        Args:
            repetitions: Number of times this operation should repeat. This
                is multiplied with any pre-existing repetitions. If unset, it
                defaults to the length of `repetition_ids`.
            repetition_ids: List of IDs, one for each repetition. If unset,
                defaults to `default_repetition_ids(repetitions)`.
            use_repetition_ids: If given, this specifies the value for `use_repetition_ids`
                of the resulting circuit operation. If not given, we enable ids if
                `repetition_ids` is not None, and otherwise fall back to
                `self.use_repetition_ids`.

        Returns:
            A copy of this operation repeated `repetitions` times with the
            appropriate `repetition_ids`. The output `repetition_ids` are the
            cartesian product of input `repetition_ids` with the base
            operation's `repetition_ids`. If the base operation has unset
            `repetition_ids` (indicates {-1, 0, 1} `repetitions` with no custom
            IDs), the input `repetition_ids` are directly used.

        Raises:
            TypeError: `repetitions` is not an integer value.
            ValueError: Unexpected length of `repetition_ids`.
            ValueError: Both `repetitions` and `repetition_ids` are None.
        
cirq-core/cirq/circuits/circuit_operation.py