code: def test_to_numpy_cast_before_setting_na():
      # GH#50600
      ser = Series([1])
      result = ser.to_numpy(dtype=np.float64, na_value=np.nan)
      expected = np.array([1.0])
      tm.assert_numpy_array_equal(result, expected)
  
imports: import numpy
  import pytest
  from pandas import NA, Series
  import pandas._testing
label_desc: Use image node_id 2 for calling a global function with example usage: test_to_numpy_cast_before_setting_na() without return types