code: def test_map_nested_num_proc(
      iterable_length, num_proc, expected_num_proc
  ):
      with patch(
          "datasets.utils.py_utils._single_map_nested"
      ) as mock_single_map_nested, patch(
          "datasets.parallel.parallel.Pool"
      ) as mock_multiprocessing_pool:
          data_struct = {f"{i}": i for i in range(iterable_length)}
          _ = map_nested(
              lambda x: x + 10,
              data_struct,
              num_proc=num_proc,
              parallel_min_length=16,
          )
          if expected_num_proc == 1:
              assert mock_single_map_nested.called
              assert not mock_multiprocessing_pool.called
          else:
              assert not mock_single_map_nested.called
              assert mock_multiprocessing_pool.called
              assert (
                  mock_multiprocessing_pool.call_args[0][0]
                  == expected_num_proc
              )
  
imports: import time
  from dataclasses import dataclass
  from multiprocessing import Pool
  from unittest import TestCase
  from unittest.mock import patch
  import multiprocess
  import numpy
  import pytest
  from datasets.utils.py_utils import NestedDataStructure, asdict, iflatmap_unordered, map_nested, temp_seed, temporary_assignment, zip_dict
  from .utils import require_tf, require_torch
label_desc: Use image node_id 3 for calling a global function with example usage: test_map_nested_num_proc(iterable_length, num_proc, expected_num_proc) without return types