original_docstring: Create a singlet UCCSD generator for a system with n_electrons
  
      This function generates a FermionOperator for a UCCSD generator designed
          to act on a single reference state consisting of n_qubits spin orbitals
          and n_electrons electrons, that is a spin singlet operator, meaning it
          conserves spin.
  
      Args:
          packed_amplitudes(ndarray): Compact array storing the unique single
              and double excitation amplitudes for a singlet UCCSD operator.
              The ordering lists unique single excitations before double
              excitations.
          n_qubits(int): Number of spin-orbitals used to represent the system,
              which also corresponds to number of qubits in a non-compact map.
          n_electrons(int): Number of electrons in the physical system.
  
      Returns:
          uccsd_generator(FermionOperator): Generator of the UCCSD operator that
              builds the UCCSD wavefunction.
      
docstring: Create a singlet UCCSD generator for a system with n_electrons
  This function generates a FermionOperator for a UCCSD generator designed
  to act on a single reference state consisting of n_qubits spin orbitals
  and n_electrons electrons, that is a spin singlet operator, meaning it
  conserves spin.
docstring_tokens: Create a singlet UCCSD generator for a system with n_electrons This function generates a FermionOperator for a UCCSD generator designed to act on a single reference state consisting of n_qubits spin orbitals and n_electrons electrons that is a spin singlet operator meaning it conserves spin .
code: def uccsd_singlet_operator(packed_amplitudes,
                             n_qubits,
                             n_electrons):
      """Create a singlet UCCSD generator for a system with n_electrons
  
      This function generates a FermionOperator for a UCCSD generator designed
          to act on a single reference state consisting of n_qubits spin orbitals
          and n_electrons electrons, that is a spin singlet operator, meaning it
          conserves spin.
  
      Args:
          packed_amplitudes(ndarray): Compact array storing the unique single
              and double excitation amplitudes for a singlet UCCSD operator.
              The ordering lists unique single excitations before double
              excitations.
          n_qubits(int): Number of spin-orbitals used to represent the system,
              which also corresponds to number of qubits in a non-compact map.
          n_electrons(int): Number of electrons in the physical system.
  
      Returns:
          uccsd_generator(FermionOperator): Generator of the UCCSD operator that
              builds the UCCSD wavefunction.
      """
      n_occupied = int(numpy.ceil(n_electrons / 2.))
      n_virtual = int(n_qubits / 2 - n_occupied)  # Virtual Spatial Orbitals
      n_t1 = int(n_occupied * n_virtual)
      n_t2 = int(n_t1 ** 2)
  
      t1 = packed_amplitudes[:n_t1]
      t2 = packed_amplitudes[n_t1:]
  
      def t1_ind(i, j):
          return i * n_occupied + j
  
      def t2_ind(i, j, k, l):
          return i * n_occupied * n_virtual * n_occupied \
              + j * n_virtual * n_occupied \
              + k * n_occupied \
              + l
  
      uccsd_generator = FermionOperator()
  
      for i in range(n_virtual):
          for j in range(n_occupied):
              for s1 in range(2):
                  uccsd_generator += FermionOperator((
                      (2 * (i + n_occupied) + s1, 1),
                      (2 * j + s1, 0)),
                      t1[t1_ind(i, j)])
  
                  uccsd_generator += FermionOperator((
                      (2 * j + s1, 1),
                      (2 * (i + n_occupied) + s1, 0)),
                      -t1[t1_ind(i, j)])
  
      for i in range(n_virtual):
          for j in range(n_occupied):
              for s1 in range(2):
                  for k in range(n_virtual):
                      for l in range(n_occupied):
                          for s2 in range(2):
                              uccsd_generator += FermionOperator((
                                  (2 * (i + n_occupied) + s1, 1),
                                  (2 * j + s1, 0),
                                  (2 * (k + n_occupied) + s2, 1),
                                  (2 * l + s2, 0)),
                                  t2[t2_ind(i, j, k, l)])
  
                              uccsd_generator += FermionOperator((
                                  (2 * l + s2, 1),
                                  (2 * (k + n_occupied) + s2, 0),
                                  (2 * j + s1, 1),
                                  (2 * (i + n_occupied) + s1, 0)),
                                  -t2[t2_ind(i, j, k, l)])
      return uccsd_generator
code_tokens: def uccsd_singlet_operator ( packed_amplitudes , n_qubits , n_electrons ) : n_occupied = int ( numpy . ceil ( n_electrons / 2. ) ) n_virtual = int ( n_qubits / 2 - n_occupied ) n_t1 = int ( n_occupied * n_virtual ) n_t2 = int ( n_t1 ** 2 ) t1 = packed_amplitudes [ : n_t1 ] t2 = packed_amplitudes [ n_t1 : ] def t1_ind ( i , j ) : return i * n_occupied + j def t2_ind ( i , j , k , l ) : return i * n_occupied * n_virtual * n_occupied + j * n_virtual * n_occupied + k * n_occupied + l uccsd_generator = FermionOperator ( ) for i in range ( n_virtual ) : for j in range ( n_occupied ) : for s1 in range ( 2 ) : uccsd_generator += FermionOperator ( ( ( 2 * ( i + n_occupied ) + s1 , 1 ) , ( 2 * j + s1 , 0 ) ) , t1 [ t1_ind ( i , j ) ] ) uccsd_generator += FermionOperator ( ( ( 2 * j + s1 , 1 ) , ( 2 * ( i + n_occupied ) + s1 , 0 ) ) , - t1 [ t1_ind ( i , j ) ] ) for i in range ( n_virtual ) : for j in range ( n_occupied ) : for s1 in range ( 2 ) : for k in range ( n_virtual ) : for l in range ( n_occupied ) : for s2 in range ( 2 ) : uccsd_generator += FermionOperator ( ( ( 2 * ( i + n_occupied ) + s1 , 1 ) , ( 2 * j + s1 , 0 ) , ( 2 * ( k + n_occupied ) + s2 , 1 ) , ( 2 * l + s2 , 0 ) ) , t2 [ t2_ind ( i , j , k , l ) ] ) uccsd_generator += FermionOperator ( ( ( 2 * l + s2 , 1 ) , ( 2 * ( k + n_occupied ) + s2 , 0 ) , ( 2 * j + s1 , 1 ) , ( 2 * ( i + n_occupied ) + s1 , 0 ) ) , - t2 [ t2_ind ( i , j , k , l ) ] ) return uccsd_generator
short_docstring: Create a singlet UCCSD generator for a system with n_electrons
  This function generates a FermionOperator for a UCCSD generator designed
  to act on a single reference state consisting of n_qubits spin orbitals
  and n_electrons electrons, that is a spin singlet operator, meaning it
  conserves spin.
short_docstring_tokens: Create a singlet UCCSD generator for a system with n_electrons This function generates a FermionOperator for a UCCSD generator designed to act on a single reference state consisting of n_qubits spin orbitals and n_electrons electrons that is a spin singlet operator meaning it conserves spin .
comment: """Create a singlet UCCSD generator for a system with n_electrons
  
      This function generates a FermionOperator for a UCCSD generator designed
          to act on a single reference state consisting of n_qubits spin orbitals
          and n_electrons electrons, that is a spin singlet operator, meaning it
          conserves spin.
  
      Args:
          packed_amplitudes(ndarray): Compact array storing the unique single
              and double excitation amplitudes for a singlet UCCSD operator.
              The ordering lists unique single excitations before double
              excitations.
          n_qubits(int): Number of spin-orbitals used to represent the system,
              which also corresponds to number of qubits in a non-compact map.
          n_electrons(int): Number of electrons in the physical system.
  
      Returns:
          uccsd_generator(FermionOperator): Generator of the UCCSD operator that
              builds the UCCSD wavefunction.
      """$SEP$# Virtual Spatial Orbitals