code: def test_rename_channels():
      """Test rename channels."""
      info = read_info(raw_fname)
      # Error Tests
      # Test channel name exists in ch_names
      mapping = {"EEG 160": "EEG060"}
      pytest.raises(ValueError, rename_channels, info, mapping)
      # Test improper mapping configuration
      mapping = {"MEG 2641": 1.0}
      pytest.raises(TypeError, rename_channels, info, mapping)
      # Test non-unique mapping configuration
      mapping = {"MEG 2641": "MEG 2642"}
      pytest.raises(ValueError, rename_channels, info, mapping)
      # Test bad input
      pytest.raises(ValueError, rename_channels, info, 1.0)
      pytest.raises(ValueError, rename_channels, info, 1.0)
  
      # Test successful changes
      # Test ch_name and ch_names are changed
      info2 = deepcopy(
          info
      )  # for consistency at the start of each test
      info2["bads"] = ["EEG 060", "EOG 061"]
      mapping = {"EEG 060": "EEG060", "EOG 061": "EOG061"}
      rename_channels(info2, mapping)
      assert info2["chs"][374]["ch_name"] == "EEG060"
      assert info2["ch_names"][374] == "EEG060"
      assert info2["chs"][375]["ch_name"] == "EOG061"
      assert info2["ch_names"][375] == "EOG061"
      assert_array_equal(["EEG060", "EOG061"], info2["bads"])
      info2 = deepcopy(info)
      rename_channels(info2, lambda x: x.replace(" ", ""))
      assert info2["chs"][373]["ch_name"] == "EEG059"
      info2 = deepcopy(info)
      info2["bads"] = ["EEG 060", "EEG 060"]
      rename_channels(info2, mapping)
      assert_array_equal(["EEG060", "EEG060"], info2["bads"])
  
      # test that keys in Raw._orig_units will be renamed, too
      raw = read_raw_fif(raw_fname).crop(0, 0.1)
      old, new = "EEG 060", "New"
      raw._orig_units = {old: "V"}
  
      raw.rename_channels({old: new})
      assert old not in raw._orig_units
      assert new in raw._orig_units
  
imports: import hashlib
  from copy import deepcopy
  from functools import partial
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from scipy.io import savemat
  from mne import Epochs, EpochsArray, EvokedArray, create_info, make_ad_hoc_cov, pick_channels, pick_types, read_events
  from mne._fiff.constants import FIFF, _ch_unit_mul_named
  from mne.channels import combine_channels, equalize_channels, find_ch_adjacency, get_builtin_ch_adjacencies, make_1020_channel_selections, read_ch_adjacency, read_custom_montage, rename_channels
  from mne.channels.channels import _BUILTIN_CHANNEL_ADJACENCIES, _BuiltinChannelAdjacency, _ch_neighbor_adjacency, _compute_ch_adjacency
  from mne.datasets import testing
  from mne.io import RawArray, read_info, read_raw_bti, read_raw_ctf, read_raw_eeglab, read_raw_fif, read_raw_kit
  from mne.parallel import parallel_func
  from mne.utils import requires_good_network
label_desc: Use image node_id 2 for calling a global function with example usage: test_rename_channels() without return types