code: def test_tags(tags, str_or_array, wrong_dtype, invalid_chars):
      """Test handling of invalid tags."""
      r = Report()
  
      if not str_or_array:
          with pytest.raises(
              TypeError, match="must be a string.*or an array.*"
          ):
              r.add_code(code="foo", title="bar", tags=tags)
      elif wrong_dtype:
          with pytest.raises(TypeError, match="tags must be strings"):
              r.add_code(code="foo", title="bar", tags=tags)
      elif invalid_chars:
          with pytest.raises(
              ValueError, match="contained invalid characters"
          ):
              r.add_code(code="foo", title="bar", tags=tags)
      else:
          r.add_code(code="foo", title="bar", tags=tags)
  
imports: import base64
  import copy
  import glob
  import os
  import pickle
  import re
  import shutil
  from io import BytesIO
  from pathlib import Path
  import numpy
  import pytest
  from matplotlib import pyplot
  from mne import Epochs, create_info, pick_channels_cov, read_cov, read_events, read_evokeds
  from mne._fiff.write import DATE_NONE
  from mne.datasets import testing
  from mne.epochs import make_metadata
  from mne.io import RawArray, read_info, read_raw_fif
  from mne.preprocessing import ICA
  from mne.report import Report, _ReportScraper, open_report, report
  from mne.report import report
  from mne.report.report import _ALLOWED_IMAGE_FORMATS, CONTENT_ORDER, _webp_supported
  from mne.utils import Bunch
  from mne.utils._testing import assert_object_equal
  from mne.viz import plot_alignment
label_desc: Use image node_id 27 for calling a global function with example usage: test_tags(tags, str_or_array, wrong_dtype, invalid_chars) without return types