code: def test_union_dtypes(left, right, expected, names):
      left = pandas_dtype(left)
      right = pandas_dtype(right)
      a = Index([], dtype=left, name=names[0])
      b = Index([], dtype=right, name=names[1])
      result = a.union(b)
      assert result.dtype == expected
      assert result.name == names[2]
  
      # Testing name retention
      # TODO: pin down desired dtype; do we want it to be commutative?
      result = a.intersection(b)
      assert result.name == names[2]
  
imports: from datetime import datetime
  import operator
  import numpy
  import pytest
  from pandas._libs import lib
  from pandas.core.dtypes.cast import find_common_type
  from pandas import CategoricalDtype, CategoricalIndex, DatetimeTZDtype, Index, MultiIndex, PeriodDtype, RangeIndex, Series, Timestamp
  import pandas._testing
  from pandas.api.types import is_signed_integer_dtype, pandas_dtype
label_desc: Use image node_id 7 for calling a global function with example usage: test_union_dtypes(left, right, expected, names) without return types