code: def test_expand_with_tight_layout():
      # Check issue reported in #10476, and updated due to #10784
      fig, ax = plt.subplots()
  
      d1 = [1, 2]
      d2 = [2, 1]
      ax.plot(d1, label="series 1")
      ax.plot(d2, label="series 2")
      ax.legend(ncols=2, mode="expand")
  
      fig.tight_layout()
  
imports: from collections import namedtuple
  import io
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  from matplotlib.testing.decorators import check_figures_equal, image_comparison
  import matplotlib.pyplot
  import matplotlib.patches
  import matplotlib.lines
  from matplotlib.backend_bases import MouseButton, MouseEvent
  from matplotlib.offsetbox import AnchoredOffsetbox, AnnotationBbox, AnchoredText, DrawingArea, HPacker, OffsetBox, OffsetImage, PaddedBox, TextArea, VPacker, _get_packed_offsets
label_desc: Use image node_id 4 for calling a global function with example usage: test_expand_with_tight_layout() without return types