code: def pick_channels_forward(
      orig,
      include=[],
      exclude=[],
      ordered=None,
      copy=True,
      *,
      verbose=None,
  ):
      """Pick channels from forward operator.
  
      Parameters
      ----------
      orig : dict
          A forward solution.
      include : list of str
          List of channels to include (if empty, include all available).
          Defaults to [].
      exclude : list of str | 'bads'
          Channels to exclude (if empty, do not exclude any). Defaults to [].
          If 'bads', then exclude bad channels in orig.
      %(ordered)s
      copy : bool
          If True (default), make a copy.
  
          .. versionadded:: 0.19
      %(verbose)s
  
      Returns
      -------
      res : dict
          Forward solution restricted to selected channels. If include and
          exclude are empty it returns orig without copy.
      """
      orig["info"]._check_consistency()
      if len(include) == 0 and len(exclude) == 0:
          return orig.copy() if copy else orig
      exclude = _check_excludes_includes(
          exclude, info=orig["info"], allow_bads=True
      )
  
      # Allow for possibility of channel ordering in forward solution being
      # different from that of the M/EEG file it is based on.
      sel_sol = pick_channels(
          orig["sol"]["row_names"],
          include=include,
          exclude=exclude,
          ordered=ordered,
      )
      sel_info = pick_channels(
          orig["info"]["ch_names"],
          include=include,
          exclude=exclude,
          ordered=ordered,
      )
  
      fwd = deepcopy(orig) if copy else orig
  
      # Check that forward solution and original data file agree on #channels
      if len(sel_sol) != len(sel_info):
          raise ValueError(
              "Forward solution and functional data appear to "
              "have different channel names, please check."
          )
  
      #   Do we have something?
      nuse = len(sel_sol)
      if nuse == 0:
          raise ValueError("Nothing remains after picking")
  
      logger.info(
          "    %d out of %d channels remain after picking"
          % (nuse, fwd["nchan"])
      )
  
      #   Pick the correct rows of the forward operator using sel_sol
      fwd["sol"]["data"] = fwd["sol"]["data"][sel_sol, :]
      fwd["_orig_sol"] = fwd["_orig_sol"][sel_sol, :]
      fwd["sol"]["nrow"] = nuse
  
      ch_names = [fwd["sol"]["row_names"][k] for k in sel_sol]
      fwd["nchan"] = nuse
      fwd["sol"]["row_names"] = ch_names
  
      # Pick the appropriate channel names from the info-dict using sel_info
      with fwd["info"]._unlock():
          fwd["info"]["chs"] = [fwd["info"]["chs"][k] for k in sel_info]
      fwd["info"]._update_redundant()
      fwd["info"]["bads"] = [
          b for b in fwd["info"]["bads"] if b in ch_names
      ]
  
      if fwd["sol_grad"] is not None:
          fwd["sol_grad"]["data"] = fwd["sol_grad"]["data"][sel_sol, :]
          fwd["_orig_sol_grad"] = fwd["_orig_sol_grad"][sel_sol, :]
          fwd["sol_grad"]["nrow"] = nuse
          fwd["sol_grad"]["row_names"] = [
              fwd["sol_grad"]["row_names"][k] for k in sel_sol
          ]
  
      return fwd
  
imports: import re
  from copy import deepcopy
  import numpy
  from ..utils import _check_option, _ensure_int, _validate_type, fill_doc, logger, verbose, warn
  from .constants import FIFF
label_desc: Use image node_id 13 for calling a global function with example usage: pick_channels_forward(orig, include, exclude, ordered, copy) and returns: fwd, unknown