code: def test_to_patches():
      dataset = foz.load_zoo_dataset("quickstart").clone()
  
      view = dataset.to_patches("ground_truth")
  
      # Patches views inherit tags from the dataset
      print(dataset.count_sample_tags())
      print(view.count_sample_tags())
  
      view.tag_samples("test")
  
      # Tagging patches has no effect on dataset samples
      print(view.count_sample_tags())
      print(dataset.count_sample_tags())
  
      view.untag_samples("test")
  
      # Untagging patches has no effect on dataset samples
      print(view.count_sample_tags())
      print(dataset.count_sample_tags())
  
      view.tag_labels("test")
  
      # Tagging patch labels immediately syncs with dataset labels
      print(view.count_label_tags())
      print(dataset.count_label_tags())
      print(dataset.count_values("ground_truth.detections.tags"))
      print(dataset.count_values("predictions.detections.tags"))
  
      view.untag_labels("test")
  
      # Untagging patch labels immediately syncs with dataset labels
      print(view.count_label_tags())
      print(dataset.count_label_tags())
      print(dataset.count_values("ground_truth.detections.tags"))
      print(dataset.count_values("predictions.detections.tags"))
  
      view2 = view.limit(100).set_field(
          "ground_truth.label", F("label").upper()
      )
      view2.save()
  
      # Saving a modified patches view syncs label modifications and deletions
      # with the dataset's labels
      print(view.count("ground_truth"))
      print(view2.count("ground_truth"))
      print(dataset.count("ground_truth.detections"))
      print(view.count_values("ground_truth.label"))
      print(view2.count_values("ground_truth.label"))
      print(dataset.count_values("ground_truth.detections.label"))
  
      sample = view.first()
  
      sample.ground_truth.hello = "world"
      sample.save()
  
      # Directly editing and saving a single patch syncs any label changes with
      # the dataset's labels
      print(view.count_values("ground_truth.hello"))
      print(dataset.count_values("ground_truth.detections.hello"))
  
      dataset.untag_samples("validation")
      view.reload()
  
      # Reloading an eval view syncs it with the source dataset's contents
      print(dataset.count_sample_tags())
      print(view.count_sample_tags())
  
imports: import unittest
  import fiftyone
  import fiftyone.zoo
  from fiftyone import ViewField
label_desc: Use image node_id 1 for calling a global function with example usage: test_to_patches() without return types