docs: def fast_sweep_steady_state(Ep, epsilonp, gamma,
                              omega_level, rm, xi, theta,
                              file_name=None, return_code=False):
      r"""Return an spectrum of density matrices in the steady state.
  
      We test a basic two-level system.
  
      >>> import numpy as np
      >>> from sympy import symbols
      >>> from scipy.constants import physical_constants
  
      >>> e_num = physical_constants["elementary charge"][0]
      >>> hbar_num = physical_constants["Planck constant over 2 pi"][0]
  
      >>> Ne = 2
      >>> Nl = 1
      >>> Ep = [-1.0]
      >>> epsilonp = [np.array([0, 0, 1.0])]
      >>> delta = symbols("delta")
  
      >>> detuning_knob = [delta]
      >>> gamma = np.array([[0.0, -1.0], [1.0, 0.0]])
      >>> omega_level = np.array([0.0, 100.0])
      >>> rm = [np.array([[0.0, 0.0], [1.0, 0.0]])*hbar_num/e_num
      ...       for p in range(3)]
      >>> xi = np.array([[[0, 1], [1, 0]]])
      >>> theta = phase_transformation(Ne, Nl, rm, xi)
      >>> sweep_steady_state = fast_sweep_steady_state(Ep, epsilonp, gamma,
      ...                                              omega_level, rm, xi,
      ...                                              theta)
      >>> deltas, rho = sweep_steady_state([[-20, 20, 11]])
      >>> print(rho)
      [[ 0.0006 -0.025  -0.0006]
       [ 0.001  -0.0312 -0.001 ]
       [ 0.0017 -0.0415 -0.0017]
       [ 0.0039 -0.0618 -0.0039]
       [ 0.0149 -0.1194 -0.0149]
       [ 0.3333 -0.     -0.3333]
       [ 0.0149  0.1194 -0.0149]
       [ 0.0039  0.0618 -0.0039]
       [ 0.0017  0.0415 -0.0017]
       [ 0.001   0.0312 -0.001 ]
       [ 0.0006  0.025  -0.0006]]
  
      """
      # We unpack variables.
      if True:
          Nl = xi.shape[0]
      # We determine which arguments are constants.
      if True:
          try:
              Ep = np.array([complex(Ep[l]) for l in range(Nl)])
              variable_Ep = False
          except:
              variable_Ep = True
  
          try:
              epsilonp = [np.array([complex(epsilonp[l][i]) for i in range(3)])
                          for l in range(Nl)]
              variable_epsilonp = False
          except:
              variable_epsilonp = True
      # We obtain code for the steady state.
      if True:
          detuning_knob = symbols("delta1:"+str(Nl))
          args = (Ep, epsilonp, detuning_knob, gamma, omega_level, rm, xi, theta,
                  file_name, True)
  
          steady_state = fast_steady_state(*args)
          code = steady_state+"\n\n"
      # We establish the arguments of the output function.
      if True:
          code += "def sweep_steady_state("
          if variable_Ep: code += "Ep, "
          if variable_epsilonp: code += "epsilonp, "
          code += "detuning_knob, "
          code += "steady_state=steady_state):\n"
          code += '    r"""A fast frequency sweep of the steady state."""\n'
      # Code to determine the sweep range.
      if True:
          code += """    sweepN = -1\n"""
          code += """    for i, delta in enumerate(detuning_knob):\n"""
          code += """        if hasattr(delta, "__getitem__"):\n"""
          code += """            sweepN = i\n"""
          code += """            delta0 = delta[0]\n"""
          code += """            deltaf = delta[1]\n"""
          code += """            Ndelta = delta[2]\n"""
          code += """            break\n\n"""
          code += """    if sweepN == -1:\n"""
          code += """        s = 'One of the detuning knobs '\n"""
          code += """        s += 'must be of the form '\n"""
          code += """        s += '(start, stop, Nsteps)'\n"""
          code += """        raise ValueError(s)\n\n"""
          code += """    deltas = np.linspace(delta0, deltaf, Ndelta)\n\n"""
      # We call steady_state.
      if True:
          code += "    args = [["
          if variable_Ep: code += "Ep, "
          if variable_epsilonp: code += "epsilonp, "
          code += """list(detuning_knob[:sweepN]) +\n"""
          code += """            [deltas[i]] +\n"""
          code += """            list(detuning_knob[sweepN+1:])]\n"""
          code += """          for i in range(Ndelta)]\n\n"""
          code += "    rho = np.array([steady_state(*argsi)\n"
          code += "                   for argsi in args])\n\n"
      # We finish the code.
      if True:
          code += "    return deltas, rho\n"
      # We write the code to file if provided, and execute it.
      if True:
          if file_name is not None:
              f = file(file_name+".py", "w")
              f.write(code)
              f.close()
  
          sweep_steady_state = code
          if not return_code:
              exec sweep_steady_state
      return sweep_steady_state