def object_tracker_scope(object_tracker: ObjectTracker):
  """A context to manage trackable objects.

  Collects all trackable objects annotated using `track_object` within the body
  of its scope.

  Args:
    object_tracker: The passed in ObjectTracker object

  Yields:
    A scope in which the object_tracker is active.
  """
  global _OBJECT_TRACKER
  # Multiple nested object_tracker_scope calls are not expected.
  assert _OBJECT_TRACKER is None
  _OBJECT_TRACKER = object_tracker
  try:
    yield
  finally:
    _OBJECT_TRACKER = None
A context to manage trackable objects.

  Collects all trackable objects annotated using `track_object` within the body
  of its scope.

  Args:
    object_tracker: The passed in ObjectTracker object

  Yields:
    A scope in which the object_tracker is active.
  
tensorflow_transform/annotators.py