code: def test_merge_samples_image(basedir):
      images_dir = os.path.join(basedir, "merge_samples_image")
      label = "person"
  
      dataset = foz.load_zoo_dataset("quickstart").clone()
  
      dataset1 = dataset.clone()
      dataset2 = dataset.clone()
      dataset3 = dataset.clone()
  
      # Give `dataset2` new field names
      dataset2.rename_sample_field("ground_truth", "gt")
  
      # Give `dataset3` new image locations
      inpaths = dataset3.values("filepath")
      outpaths = [
          os.path.join(images_dir, os.path.basename(f)) for f in inpaths
      ]
      for inpath, outpath in zip(inpaths, outpaths):
          etau.copy_file(inpath, outpath)
  
      dataset3.set_values("filepath", outpaths)
  
      # Only merge `person` labels
      view2 = dataset2.filter_labels("gt", F("label") == label)
      view3 = dataset3.filter_labels(
          "ground_truth", F("label") == label
      )
  
      # Perform the merges
      dataset.merge_samples(view2)
      dataset.merge_samples(view3)
  
      # Check that schema is correct
      schema = dataset.get_field_schema()
  
      assert "ground_truth" in schema
      assert "gt" in schema
  
      #
      # `dataset` should contain:
      #   `view2` counts in its `gt` field
      #   `dataset1` + `view3` counts in its `ground_truth` field
      #
  
      dataset_counts = dataset.count_values(
          "ground_truth.detections.label"
      )
      dataset1_counts = dataset1.count_values(
          "ground_truth.detections.label"
      )
      view3_counts = view3.count_values("ground_truth.detections.label")
  
      assert dataset_counts[label] == (
          dataset1_counts[label] + view3_counts[label]
      )
  
      dataset_counts = dataset.count_values("gt.detections.label")
      view2_counts = view2.count_values("gt.detections.label")
  
      assert dataset_counts[label] == view2_counts[label]
  
file_path: fiftyone/tests/intensive/merge_tests.py
imports: import os
  import pytest
  import eta.core.utils
  import fiftyone
  import fiftyone.zoo
  from fiftyone import ViewField
label_desc: Use image node_id 2 for calling a global function with example usage: test_merge_samples_image(basedir) without return types