def _sign_grad(
        self, x_0: np.ndarray, y_0: int, epsilon: float, theta: np.ndarray, initial_lbd: float, target: int | None
    ) -> tuple[np.ndarray, int]:
        """
        Evaluate the sign of gradient

        :param x_0: An array with the original inputs to be attacked.
        :param y_0: Target value.
        :param epsilon: A very small smoothing parameter.
        :param theta: Initial query direction.
        :param initial_lbd: Previous solution.
        :param target: Target value. If `self.targeted` is true, it presents the targeted label. Defaults to None.
        :return: the sign of gradient
        """
        sign_grad = np.zeros(theta.shape).astype(np.float32)
        queries = 0
        # use orthogonal transform
        for _ in range(self.k):  # for each u
            # Algorithm 1: Sign-OPT attack
            #     A:Randomly sample u1, . . . , uQ from a Gaussian or Uniform distribution;
            u_g = np.random.randn(*theta.shape).astype(np.float32)
            # gaussian
            u_g /= np.linalg.norm(u_g)
            # function (3) in the paper
            new_theta = theta + epsilon * u_g
            new_theta /= np.linalg.norm(new_theta)
            sign = 1

            if self.targeted and self._is_label(x_0 + initial_lbd * new_theta, target):
                sign = -1
            elif not self.targeted and not self._is_label(x_0 + initial_lbd * new_theta, y_0):
                sign = -1

            queries += 1
            sign_grad += u_g * sign

        sign_grad /= self.k

        return sign_grad, queries

        Evaluate the sign of gradient

        :param x_0: An array with the original inputs to be attacked.
        :param y_0: Target value.
        :param epsilon: A very small smoothing parameter.
        :param theta: Initial query direction.
        :param initial_lbd: Previous solution.
        :param target: Target value. If `self.targeted` is true, it presents the targeted label. Defaults to None.
        :return: the sign of gradient
        
art/attacks/evasion/sign_opt.py