code: def _prepare_beamformer_input(
      info,
      forward,
      label=None,
      pick_ori=None,
      noise_cov=None,
      rank=None,
      pca=False,
      loose=None,
      combine_xyz="fro",
      exp=None,
      limit=None,
      allow_fixed_depth=True,
      limit_depth_chs=False,
  ):
      """Input preparation common for LCMV, DICS, and RAP-MUSIC."""
      _check_option(
          "pick_ori", pick_ori, ("normal", "max-power", "vector", None)
      )
  
      # Restrict forward solution to selected vertices
      if label is not None:
          _, src_sel = label_src_vertno_sel(label, forward["src"])
          forward = _restrict_forward_to_src_sel(forward, src_sel)
  
      if loose is None:
          loose = 0.0 if is_fixed_orient(forward) else 1.0
      # TODO: Deduplicate with _check_one_ch_type, should not be necessary
      # (DICS hits this code path, LCMV does not)
      if noise_cov is None:
          noise_cov = make_ad_hoc_cov(info, std=1.0)
      (
          forward,
          info_picked,
          gain,
          _,
          orient_prior,
          _,
          trace_GRGT,
          noise_cov,
          whitener,
      ) = _prepare_forward(
          forward,
          info,
          noise_cov,
          "auto",
          loose,
          rank=rank,
          pca=pca,
          use_cps=True,
          exp=exp,
          limit_depth_chs=limit_depth_chs,
          combine_xyz=combine_xyz,
          limit=limit,
          allow_fixed_depth=allow_fixed_depth,
      )
      is_free_ori = not is_fixed_orient(
          forward
      )  # could have been changed
      nn = forward["source_nn"]
      if is_free_ori:  # take Z coordinate
          nn = nn[2::3]
      nn = nn.copy()
      vertno = _get_vertno(forward["src"])
      if forward["surf_ori"]:
          nn[...] = [0, 0, 1]  # align to local +Z coordinate
      if pick_ori is not None and not is_free_ori:
          raise ValueError(
              f"Normal or max-power orientation (got {pick_ori!r}) can only be picked "
              "when a forward operator with free orientation is used."
          )
      if pick_ori == "normal" and not forward["surf_ori"]:
          raise ValueError(
              "Normal orientation can only be picked when a forward operator oriented in "
              "surface coordinates is used."
          )
      _check_src_normal(pick_ori, forward["src"])
      del forward, info
  
      # Undo the scaling that MNE prefers
      scale = np.sqrt((noise_cov["eig"] > 0).sum() / trace_GRGT)
      gain /= scale
      if orient_prior is not None:
          orient_std = np.sqrt(orient_prior)
      else:
          orient_std = np.ones(gain.shape[1])
  
      # Get the projector
      proj, _, _ = make_projector(
          info_picked["projs"], info_picked["ch_names"]
      )
      return (
          is_free_ori,
          info_picked,
          proj,
          vertno,
          gain,
          whitener,
          nn,
          orient_std,
      )
  
imports: from copy import deepcopy
  import numpy
  from .._fiff.proj import Projection, make_projector
  from ..cov import Covariance, make_ad_hoc_cov
  from ..forward.forward import _restrict_forward_to_src_sel, is_fixed_orient
  from ..minimum_norm.inverse import _get_vertno, _prepare_forward
  from ..source_space._source_space import label_src_vertno_sel
  from ..time_frequency.csd import CrossSpectralDensity
  from ..utils import _check_option, _check_src_normal, _import_h5io_funcs, _pl, _reg_pinv, _sym_mat_pow, check_fname, logger, verbose, warn
label_desc: Use image node_id 3 for calling a global function with example usage: _prepare_beamformer_input(info, forward, label, pick_ori, noise_cov, rank, pca, loose, combine_xyz, exp, limit, allow_fixed_depth, limit_depth_chs) and returns: is_free_ori,  info_picked,  proj,  vertno,  gain,  whitener,  nn,  orient_std