code: def test_picks_by_channels():
      """Test creating pick_lists."""
      rng = np.random.RandomState(909)
  
      test_data = rng.random_sample((4, 2000))
      ch_names = ["MEG %03d" % i for i in [1, 2, 3, 4]]
      ch_types = ["grad", "mag", "mag", "eeg"]
      sfreq = 250.0
      info = create_info(
          ch_names=ch_names, sfreq=sfreq, ch_types=ch_types
      )
      _assert_channel_types(info)
      raw = RawArray(test_data, info)
  
      pick_list = _picks_by_type(raw.info)
      assert len(pick_list) == 3
      assert pick_list[0][0] == "mag"
      pick_list2 = _picks_by_type(raw.info, meg_combined=False)
      assert len(pick_list) == len(pick_list2)
      assert pick_list2[0][0] == "mag"
  
      pick_list2 = _picks_by_type(raw.info, meg_combined=True)
      assert len(pick_list) == len(pick_list2) + 1
      assert pick_list2[0][0] == "meg"
  
      test_data = rng.random_sample((4, 2000))
      ch_names = ["MEG %03d" % i for i in [1, 2, 3, 4]]
      ch_types = ["mag", "mag", "mag", "mag"]
      sfreq = 250.0
      info = create_info(
          ch_names=ch_names, sfreq=sfreq, ch_types=ch_types
      )
      raw = RawArray(test_data, info)
      # This acts as a set, not an order
      assert_array_equal(
          pick_channels(
              info["ch_names"], ["MEG 002", "MEG 001"], ordered=False
          ),
          [0, 1],
      )
  
      # Make sure checks for list input work.
      pytest.raises(ValueError, pick_channels, ch_names, "MEG 001")
      pytest.raises(
          ValueError, pick_channels, ch_names, ["MEG 001"], "hi"
      )
  
      pick_list = _picks_by_type(raw.info)
      assert len(pick_list) == 1
      assert pick_list[0][0] == "mag"
      pick_list2 = _picks_by_type(raw.info, meg_combined=True)
      assert len(pick_list) == len(pick_list2)
      assert pick_list2[0][0] == "mag"
  
      # pick_types type check
      with pytest.raises(ValueError, match="must be of type"):
          raw.pick_types(eeg="string")
  
      # duplicate check
      names = ["MEG 002", "MEG 002"]
      assert (
          len(pick_channels(raw.info["ch_names"], names, ordered=False))
          == 1
      )
      with pytest.warns(FutureWarning, match="ordered=False"):
          assert (
              len(raw.copy().pick_channels(names)[0][0]) == 1
          )  # legacy method OK here
  
      # missing ch_name
      bad_names = names + ["BAD"]
      with pytest.raises(ValueError, match="Missing channels"):
          pick_channels(raw.info["ch_names"], bad_names, ordered=True)
      with pytest.raises(ValueError, match="Missing channels"):
          raw.copy().pick_channels(
              bad_names, ordered=True
          )  # legacy method OK here
      with pytest.raises(ValueError, match="could not be picked"):
          raw.copy().pick(bad_names)
  
imports: from copy import deepcopy
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from mne import Epochs, channel_indices_by_type, channel_type, create_info, make_ad_hoc_cov, pick_channels, pick_channels_cov, pick_channels_regexp, pick_info, pick_types, pick_types_forward, read_forward_solution, rename_channels
  from mne._fiff.constants import FIFF
  from mne._fiff.pick import _DATA_CH_TYPES_SPLIT, _contains_ch_type, _picks_by_type, _picks_to_idx, get_channel_type_constants
  from mne.channels import make_standard_montage
  from mne.datasets import testing
  from mne.io import RawArray, read_info, read_raw_bti, read_raw_fif, read_raw_kit
  from mne.preprocessing import compute_current_source_density
  from mne.utils import assert_object_equal, catch_logging
label_desc: Use image node_id 16 for calling a global function with example usage: test_picks_by_channels() without return types