code: def test_strict_map_output(ray_start_regular_shared):
      ds = ray.data.range(1)
  
      with pytest.raises(ValueError):
          ds.map(lambda x: 0, max_retries=0).materialize()
      ds.map(lambda x: {"id": 0}).materialize()
      ds.map(lambda x: UserDict({"id": 0})).materialize()
  
      with pytest.raises(ValueError):
          ds.map_batches(
              lambda x: np.array([0]), max_retries=0
          ).materialize()
      ds.map_batches(lambda x: {"id": [0]}).materialize()
      ds.map_batches(lambda x: UserDict({"id": [0]})).materialize()
  
      with pytest.raises(ValueError):
          ds.map(lambda x: np.ones(10), max_retries=0).materialize()
      ds.map(lambda x: {"x": np.ones(10)}).materialize()
      ds.map(lambda x: UserDict({"x": np.ones(10)})).materialize()
  
      with pytest.raises(ValueError):
          ds.map_batches(
              lambda x: np.ones(10), max_retries=0
          ).materialize()
      ds.map_batches(lambda x: {"x": np.ones(10)}).materialize()
      ds.map_batches(
          lambda x: UserDict({"x": np.ones(10)})
      ).materialize()
  
      # Not allowed in normal mode either.
      with pytest.raises(ValueError):
          ds.map_batches(
              lambda x: object(), max_retries=0
          ).materialize()
      with pytest.raises(ValueError):
          ds.map_batches(
              lambda x: {"x": object()}, max_retries=0
          ).materialize()
      ds.map_batches(lambda x: {"x": [object()]}).materialize()
      ds.map_batches(
          lambda x: UserDict({"x": [object()]})
      ).materialize()
  
      with pytest.raises(ValueError):
          ds.map(lambda x: object(), max_retries=0).materialize()
      ds.map(lambda x: {"x": object()}).materialize()
      ds.map(lambda x: UserDict({"x": object()})).materialize()
  
file_path: ray/python/ray/data/tests/test_strict_mode.py
imports: from collections import UserDict
  import numpy
  import pytest
  import ray
  from ray.data.tests.conftest import *
  from ray.tests.conftest import *
label_desc: Use image node_id 2 for calling a global function with example usage: test_strict_map_output(ray_start_regular_shared) without return types