code: def test_to_frame_patches():
      dataset = foz.load_zoo_dataset("quickstart-video").clone()
  
      dataset.tag_samples("test")
  
      frames = dataset.to_frames(sample_frames=True)
      patches = frames.to_patches("detections")
  
      # Frames and patches inherit sample tags
      print(dataset.count_sample_tags())
      print(frames.count_sample_tags())
      print(patches.count_sample_tags())
  
      patches.tag_samples("patches")
  
      # Tagging frame patches has no effect on the source datasets
      print(dataset.count_sample_tags())
      print(frames.count_sample_tags())
      print(patches.count_sample_tags())
  
      patches.untag_samples("patches")
  
      # Untagging frames has no effect on the source datasets
      print(dataset.count_sample_tags())
      print(frames.count_sample_tags())
      print(patches.count_sample_tags())
  
      patches.tag_labels("test")
  
      # Tagging patch labels applies to the source datasets
      print(patches.count_label_tags())
      print(patches.count_values("detections.tags"))
      print(frames.count_label_tags())
      print(frames.count_values("detections.detections.tags"))
      print(dataset.count_label_tags())
      print(dataset.count_values("frames.detections.detections.tags"))
  
      patches.untag_labels("test")
  
      # Untagging labels applies to the source datasets
      print(patches.count_label_tags())
      print(patches.count_values("detections.tags"))
      print(frames.count_label_tags())
      print(frames.count_values("detections.detections.tags"))
      print(dataset.count_label_tags())
      print(dataset.count_values("frames.detections.detections.tags"))
  
      view = patches.limit(100).set_field(
          "detections.label", F("label").upper()
      )
  
      # Views can be created, but don't affect source datasets until saved
      print(view.count("detections"))
      print(patches.count("detections"))
      print(frames.count("detections.detections"))
      print(dataset.count("frames.detections.detections"))
      print(view.count_values("detections.label"))
      print(patches.count_values("detections.label"))
      print(frames.count_values("detections.detections.label"))
      print(dataset.count_values("frames.detections.detections.label"))
  
      view.save()
  
      # Changes and deletions are synced with source datasets
      print(view.count("detections"))
      print(patches.count("detections"))
      print(frames.count("detections.detections"))
      print(dataset.count("frames.detections.detections"))
      print(view.count_values("detections.label"))
      print(patches.count_values("detections.label"))
      print(frames.count_values("detections.detections.label"))
      print(dataset.count_values("frames.detections.detections.label"))
  
      # Ensure that data is correctly formed
      print(view.first().frame_id)
      print(patches.first().frame_id)
      print(frames.first().id)
      print(dataset.first().frames.first().id)
  
      sample = view.first()
  
      sample["hello"] = "world"
      sample.save()
  
      # New sample-level patch fields are not synced
      print(view.count_values("hello"))
      print(patches.count_values("hello"))
      assert "hello" not in frames.get_field_schema()
      assert "hello" not in dataset.get_frame_field_schema()
  
      sample.detections.hello = "world"
      sample.save()
  
      # Patch label changes are synced to source datasets
      print(view.count_values("detections.hello"))
      print(patches.count_values("detections.hello"))
      print(frames.count_values("detections.detections.hello"))
      print(dataset.count_values("frames.detections.detections.hello"))
  
      dataset.untag_samples("test")
      patches.reload()
  
      # Reloading a frame patches view syncs it with the source datasets
      print(dataset.count_sample_tags())
      print(frames.count_sample_tags())
      print(patches.count_sample_tags())
  
file_path: fiftyone/tests/intensive/video_tests.py
imports: import random
  import unittest
  import fiftyone
  import fiftyone.zoo
  from fiftyone import ViewField
  import fiftyone.utils.video
label_desc: Use image node_id 4 for calling a global function with example usage: test_to_frame_patches() without return types