code: def test_map_error_when_not_empty(monkeypatch, tmpdir):
      boto3 = mock.MagicMock()
      client_s3_mock = mock.MagicMock()
      client_s3_mock.list_objects_v2.return_value = {
          "KeyCount": 1,
          "Contents": [],
      }
      boto3.client.return_value = client_s3_mock
      monkeypatch.setattr(resolver, "boto3", boto3)
  
      with pytest.raises(
          RuntimeError,
          match="data and datasets are meant to be immutable",
      ):
          map(
              map_fn,
              [0, 1],
              output_dir=lightning_cloud.resolver.Dir(
                  path=None, url="s3://bucket"
              ),
              error_when_not_empty=True,
          )
  
      with pytest.raises(OSError, match="cache"):
          map(
              map_fn,
              [0, 1],
              output_dir=lightning_cloud.resolver.Dir(
                  path=None, url="s3://bucket"
              ),
              error_when_not_empty=False,
          )
  
imports: import os
  import random
  import sys
  from typing import Any, List
  from unittest import mock
  import lightning_cloud
  import numpy
  import pytest
  import torch
  from lightning import seed_everything
  from lightning.data.streaming import data_processor
  from lightning.data.streaming import functions
  from lightning.data.streaming.cache import Cache, Dir
  from lightning.data.streaming.data_processor import DataChunkRecipe, DataProcessor, DataTransformRecipe, _download_data_target, _get_item_filesizes, _map_items_to_workers_sequentially, _map_items_to_workers_weighted, _remove_target, _upload_fn, _wait_for_disk_usage_higher_than_threshold, _wait_for_file_to_exist
  from lightning.data.streaming.functions import LambdaDataTransformRecipe, map, optimize
  from lightning_cloud import resolver
  from lightning_utilities.core.imports import RequirementCache
label_desc: Use image node_id 26 for calling a global function with example usage: test_map_error_when_not_empty(monkeypatch, tmpdir) without return types