code: def test_contains_nan(any_string_dtype):
      # PR #14171
      s = Series([np.nan, np.nan, np.nan], dtype=any_string_dtype)
  
      result = s.str.contains("foo", na=False)
      expected_dtype = (
          np.bool_
          if any_string_dtype in object_pyarrow_numpy
          else "boolean"
      )
      expected = Series([False, False, False], dtype=expected_dtype)
      tm.assert_series_equal(result, expected)
  
      result = s.str.contains("foo", na=True)
      expected = Series([True, True, True], dtype=expected_dtype)
      tm.assert_series_equal(result, expected)
  
      result = s.str.contains("foo", na="foo")
      if any_string_dtype == "object":
          expected = Series(["foo", "foo", "foo"], dtype=np.object_)
      elif any_string_dtype == "string[pyarrow_numpy]":
          expected = Series([True, True, True], dtype=np.bool_)
      else:
          expected = Series([True, True, True], dtype="boolean")
      tm.assert_series_equal(result, expected)
  
      result = s.str.contains("foo")
      expected_dtype = (
          "object"
          if any_string_dtype in object_pyarrow_numpy
          else "boolean"
      )
      expected = Series([np.nan, np.nan, np.nan], dtype=expected_dtype)
      tm.assert_series_equal(result, expected)
  
imports: from datetime import datetime
  import re
  import numpy
  import pytest
  from pandas.errors import PerformanceWarning
  import pandas.util._test_decorators
  import pandas
  from pandas import Series, _testing
  from pandas.tests.strings import _convert_na_value, object_pyarrow_numpy
label_desc: Use image node_id 7 for calling a global function with example usage: test_contains_nan(any_string_dtype) without return types