code: def active_space(
      electrons,
      orbitals,
      mult=1,
      active_electrons=None,
      active_orbitals=None,
  ):
      r"""Build the active space for a given number of active electrons and active orbitals.
  
      Post-Hartree-Fock (HF) electron correlation methods expand the many-body wave function
      as a linear combination of Slater determinants, commonly referred to as configurations.
      This configurations are generated by exciting electrons from the occupied to the
      unoccupied HF orbitals as sketched in the figure below. Since the number of configurations
      increases combinatorially with the number of electrons and orbitals this expansion can be
      truncated by defining an active space.
  
      The active space is created by classifying the HF orbitals as core, active and
      external orbitals:
  
      - Core orbitals are always occupied by two electrons
      - Active orbitals can be occupied by zero, one, or two electrons
      - The external orbitals are never occupied
  
      |
  
      .. figure:: ../../_static/qchem/sketch_active_space.png
          :align: center
          :width: 50%
  
      |
  
      .. note::
          The number of active *spin*-orbitals ``2*active_orbitals`` determines the number of
          qubits required to perform the quantum simulations of the electronic structure
          of the many-electron system.
  
      Args:
          electrons (int): total number of electrons
          orbitals (int): total number of orbitals
          mult (int): Spin multiplicity :math:`\mathrm{mult}=N_\mathrm{unpaired} + 1` for
              :math:`N_\mathrm{unpaired}` unpaired electrons occupying the HF orbitals.
              Possible values for ``mult`` are :math:`1, 2, 3, \ldots`. If not specified,
              a closed-shell HF state is assumed.
          active_electrons (int): Number of active electrons. If not specified, all electrons
              are treated as active.
          active_orbitals (int): Number of active orbitals. If not specified, all orbitals
              are treated as active.
  
      Returns:
          tuple: lists of indices for core and active orbitals
  
      **Example**
  
      >>> electrons = 4
      >>> orbitals = 4
      >>> core, active = active_space(electrons, orbitals, active_electrons=2, active_orbitals=2)
      >>> print(core) # core orbitals
      [0]
      >>> print(active) # active orbitals
      [1, 2]
      """
      # pylint: disable=too-many-branches
  
      if active_electrons is None:
          ncore_orbs = 0
          core = []
      else:
          if active_electrons <= 0:
              raise ValueError(
                  f"The number of active electrons ({active_electrons}) "
                  f"has to be greater than 0."
              )
  
          if active_electrons > electrons:
              raise ValueError(
                  f"The number of active electrons ({active_electrons}) "
                  f"can not be greater than the total "
                  f"number of electrons ({electrons})."
              )
  
          if active_electrons < mult - 1:
              raise ValueError(
                  f"For a reference state with multiplicity {mult}, "
                  f"the number of active electrons ({active_electrons}) should be "
                  f"greater than or equal to {mult - 1}."
              )
  
          if mult % 2 == 1:
              if active_electrons % 2 != 0:
                  raise ValueError(
                      f"For a reference state with multiplicity {mult}, "
                      f"the number of active electrons ({active_electrons}) should be even."
                  )
          else:
              if active_electrons % 2 != 1:
                  raise ValueError(
                      f"For a reference state with multiplicity {mult}, "
                      f"the number of active electrons ({active_electrons}) should be odd."
                  )
  
          ncore_orbs = (electrons - active_electrons) // 2
          core = list(range(ncore_orbs))
  
      if active_orbitals is None:
          active = list(range(ncore_orbs, orbitals))
      else:
          if active_orbitals <= 0:
              raise ValueError(
                  f"The number of active orbitals ({active_orbitals}) "
                  f"has to be greater than 0."
              )
  
          if ncore_orbs + active_orbitals > orbitals:
              raise ValueError(
                  f"The number of core ({ncore_orbs}) + active orbitals ({active_orbitals}) cannot "
                  f"be greater than the total number of orbitals ({orbitals})"
              )
  
          homo = (electrons + mult - 1) / 2
          if ncore_orbs + active_orbitals <= homo:
              raise ValueError(
                  f"For n_active_orbitals={active_orbitals}, there are no virtual orbitals "
                  f"in the active space."
              )
  
          active = list(range(ncore_orbs, ncore_orbs + active_orbitals))
  
      return core, active
  
file_path: pennylane/pennylane/qchem/structure.py
imports: import os
  import re
  from shutil import copyfile
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: active_space(electrons, orbitals, mult, active_electrons, active_orbitals) and returns: core,  active