class_docstr: A controlled mod gate.
  
  This is black box controlled Mod function for use by shor's algorithm.
  TODO: implement a decompose property that returns how to do this in terms
  of elementary gates
class_docstr_tok: ["A","controlled","mod","gate",".","This","is","black","box","controlled","Mod","function","for","use","by","shor","'s","algorithm",".","TODO",":","implement","a","decompose","property","that","returns","how","to","do","this","in","terms","of","elementary","gates"]
docstr: This directly calculates the controlled mod of the second half of
  the register and puts it in the second
  This will look pretty when we get Tensor Symbolically working
docstr_tok: ["This","directly","calculates","the","controlled","mod","of","the","second","half","of","the","register","and","puts","it","in","the","second","This","will","look","pretty","when","we","get","Tensor","Symbolically","working"]
code: def _apply_operator_Qubit(self, qubits, **options):
      """
      This directly calculates the controlled mod of the second half of
      the register and puts it in the second
      This will look pretty when we get Tensor Symbolically working
      """
      n = 1
      k = 0
      # Determine the value stored in high memory.
      for i in range(self.t):
          k += n * qubits[self.t + i]
          n *= 2
  
      # The value to go in low memory will be out.
      out = int(self.a**k % self.N)
  
      # Create array for new qbit-ket which will have high memory unaffected
      outarray = list(qubits.args[0][: self.t])
  
      # Place out in low memory
      for i in reversed(range(self.t)):
          outarray.append((out >> i) & 1)
  
      return Qubit(*outarray)
  
imports: import math
  import random
  from sympy.core.mul import Mul
  from sympy.core.singleton import S
  from sympy.functions.elementary.exponential import log
  from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.core.intfunc import igcd
  from sympy.ntheory import continued_fraction_periodic
  from sympy.utilities.iterables import variations
  from sympy.physics.quantum.gate import Gate
  from sympy.physics.quantum.qubit import Qubit, measure_partial_oneshot
  from sympy.physics.quantum.qapply import qapply
  from sympy.physics.quantum.qft import QFT
  from sympy.physics.quantum.qexpr import QuantumError
label_desc: Use image node_id 5 for calling the CMod obj's underlying member method code with example usage: obj._apply_operator_Qubit(qubits) and returns: Qubit