def num_qubits(self, circuit_index=None) -> int:
        """Returns the number of qubits for the job.

        Raises:
            IonQUnsuccessfulJob: If the job has failed, been canceled, or deleted.
            IonQException: If unable to get the status of the job from the API.
        """
        self._check_if_unsuccessful()
        if 'metadata' in self._job and circuit_index is not None:
            if 'qubit_numbers' in self._job['metadata'].keys():
                qubit_numbers = json.loads(self._job['metadata']['qubit_numbers'])
                for index, qubit_number in enumerate(qubit_numbers):
                    if index == circuit_index:
                        return qubit_number

        return int(self._job['qubits'])
Returns the number of qubits for the job.

        Raises:
            IonQUnsuccessfulJob: If the job has failed, been canceled, or deleted.
            IonQException: If unable to get the status of the job from the API.
        
cirq-ionq/cirq_ionq/job.py