docs: def decompose_once(val: Any,
                     default=RaiseTypeErrorIfNotProvided,
                     **kwargs):
      """Decomposes a value into operations, if possible.
  
      This method decomposes the value exactly once, instead of decomposing it
      and then continuing to decomposing the decomposed operations recursively
      until some criteria is met (which is what `cirq.decompose` does).
  
      Args:
          val: The value to call `_decompose_` on, if possible.
          default: A default result to use if the value doesn't have a
              `_decompose_` method or that method returns `NotImplemented` or
              `None`. If not specified, undecomposable values cause a `TypeError`.
          kwargs: Arguments to forward into the `_decompose_` method of `val`.
              For example, this is used to tell gates what qubits they are being
              applied to.
  
      Returns:
          The result of `val._decompose_(**kwargs)`, if `val` has a `_decompose_`
          method and it didn't return `NotImplemented` or `None`. Otherwise
          `default` is returned, if it was specified. Otherwise an error is
          raised.
  
      TypeError:
          `val` didn't have a `_decompose_` method (or that method returned
          `NotImplemented` or `None`) and `default` wasn't set.
      """
      method = getattr(val, '_decompose_', None)
      decomposed = NotImplemented if method is None else method(**kwargs)
  
      if decomposed is not NotImplemented and decomposed is not None:
          from cirq import ops  # HACK: Avoids circular dependencies.
          return list(ops.flatten_op_tree(decomposed))
  
      if default is not RaiseTypeErrorIfNotProvided:
          return default
      if method is None:
          raise TypeError("object of type '{}' "
                          "has no _decompose_ method.".format(type(val)))
      raise TypeError("object of type '{}' does have a _decompose_ method, "
                      "but it returned NotImplemented or None.".format(type(val)))