code: def test_fetch_frame_label():
      # x0 goes from 0 to 1 over different periods of time, and speaking_label
      # toggles. Other labels are unchanged.
      rectangles_dict = {
          "identity0": [
              {
                  "timestamp": 0.0,
                  "x0": 0,
                  "y0": 0,
                  "x1": 1,
                  "y1": 1,
                  "speaking_label": False,
                  "is_visible": True,
                  "looking_label": False,
              },
              {
                  "timestamp": 1.0,
                  "x0": 1,
                  "y0": 0,
                  "x1": 1,
                  "y1": 1,
                  "speaking_label": True,
                  "is_visible": True,
                  "looking_label": False,
              },
          ],
          "identity1": [
              {
                  "timestamp": 0.0,
                  "x0": 0,
                  "y0": 0,
                  "x1": 1,
                  "y1": 1,
                  "speaking_label": True,
                  "is_visible": True,
                  "looking_label": False,
              },
              {
                  "timestamp": 0.25,
                  "x0": 1,
                  "y0": 0,
                  "x1": 1,
                  "y1": 1,
                  "speaking_label": False,
                  "is_visible": True,
                  "looking_label": False,
              },
          ],
      }
  
      def _fetch_frame_label_fn(timestamp):
          return video._fetch_frame_label(
              "speaking_label",
              timestamp,
              rectangles_dict,
              carry_over_keys=[
                  "speaking_label",
                  "looking_label",
                  "is_visible",
              ],
              required_keys=["speaking_label", "looking_label"],
          )
  
      # Test the first label.
      ret = _fetch_frame_label_fn(0)
      assert ret["identity0"] == rectangles_dict["identity0"][0]
      assert ret["identity1"] == rectangles_dict["identity1"][0]
  
      # Test an interpolated label.
      ret = _fetch_frame_label_fn(0.25)
      expected_id0 = rectangles_dict["identity0"][0].copy()
      expected_id0["x0"] = 0.25
      expected_id0["timestamp"] = 0.25
      assert ret["identity0"] == expected_id0
  
      assert ret["identity1"] == rectangles_dict["identity1"][1]
  
      # We should get an interpolated label for identity0, and an "empty" label
      # for identity1 since there are no more labels.
      ret = _fetch_frame_label_fn(0.5)
      expected_id0 = rectangles_dict["identity0"][0].copy()
      expected_id0["x0"] = 0.50
      expected_id0["timestamp"] = 0.50
      expected_id0["speaking_label"] = False
      assert ret["identity0"] == expected_id0
      assert ret["identity1"] == _get_invalid_label(0.50)
  
      # We should get empty labels.
      ret = _fetch_frame_label_fn(-1)
      expected_id0 = _get_invalid_label(-1)
      assert ret["identity0"] == expected_id0
  
      expected_id1 = _get_invalid_label(-1)
      assert ret["identity1"] == expected_id1
  
imports: from typing import Dict
  import pytest
  import torch
  from data.datasets.utils import video
label_desc: Use image node_id 2 for calling a global function with example usage: test_fetch_frame_label() and returns: video