code: def test_optional():
      from pybind11_tests import (
          double_or_zero,
          half_or_none,
          test_nullopt,
      )
  
      assert double_or_zero(None) == 0
      assert double_or_zero(42) == 84
      pytest.raises(TypeError, double_or_zero, "foo")
  
      assert half_or_none(0) is None
      assert half_or_none(42) == 21
      pytest.raises(TypeError, half_or_none, "foo")
  
      assert test_nullopt() == 42
      assert test_nullopt(None) == 42
      assert test_nullopt(42) == 42
      assert test_nullopt(43) == 43
  
file_path: coremltools/deps/pybind11/tests/test_python_types.py
imports: import pytest
  from pybind11_tests import ExamplePythonTypes, ConstructorStats, has_optional, has_exp_optional
label_desc: Use image node_id 11 for calling a global function with example usage: test_optional() without return types