code: def _compare_local_to_utc(tz_didx, naive_didx):
      # Check that tz_localize behaves the same vectorized and pointwise.
      err1 = err2 = None
      try:
          result = tzconversion.tz_localize_to_utc(
              naive_didx.asi8, tz_didx.tz
          )
          err1 = None
      except Exception as err:
          err1 = err
  
      try:
          expected = naive_didx.map(
              lambda x: x.tz_localize(tz_didx.tz)
          ).asi8
      except Exception as err:
          err2 = err
  
      if err1 is not None:
          assert type(err1) == type(err2)
      else:
          assert err2 is None
          tm.assert_numpy_array_equal(result, expected)
  
file_path: pandas/pandas/tests/tslibs/test_conversion.py
imports: from datetime import datetime
  import numpy
  import pytest
  from pytz import UTC
  from pandas._libs.tslibs import OutOfBoundsTimedelta, astype_overflowsafe, conversion, iNaT, timezones, tz_convert_from_utc, tzconversion
  from pandas import Timestamp, date_range
  import pandas._testing
label_desc: Use image node_id 2 for calling a global function with example usage: _compare_local_to_utc(tz_didx, naive_didx) without return types