Find a running TensorBoard instance compatible with the cache key.

  Returns:
    A `TensorBoardInfo` object, or `None` if none matches the cache key.

def _find_matching_instance(cache_key):
  """Find a running TensorBoard instance compatible with the cache key.

  Returns:
    A `TensorBoardInfo` object, or `None` if none matches the cache key.
  """
  infos = get_all()
  candidates = [info for info in infos if info.cache_key == cache_key]
  for candidate in sorted(candidates, key=lambda x: x.port):
    # TODO(@wchargin): Check here that the provided port is still live.
    return candidate
  return None