code: def assert_callbacks(self, spy, num: int, algo: SpaceTransform[PBT]):
      def check_population_size(gen_population_size, depth, expected):
          assert (
              gen_population_size == expected
          ), f"population of {gen_population_size} at depth {depth}, should be {expected}"
  
      pbt = algo.algorithm
      remaining_num = num
  
      for depth in range(generations):
          gen_population_size = len(
              pbt.lineages.get_trials_at_depth(depth)
          )
          if remaining_num > population_size:
              expected_population_size = population_size
          else:
              expected_population_size = remaining_num
  
          check_population_size(
              gen_population_size, depth, expected_population_size
          )
  
          remaining_num = max(
              remaining_num - expected_population_size, 0
          )
  
imports: from __future__ import annotations
  import functools
  import logging
  from typing import ClassVar
  import numpy
  import pytest
  from base import ExploitStub, ExploreStub, sample_trials
  from pytest_mock import MockerFixture
  from orion.algo.pbt.pbt import PBT, compute_fidelities
  from orion.algo.space import Space
  from orion.core.worker.primary_algo import SpaceTransform, create_algo
  from orion.core.worker.transformer import ReshapedSpace, TransformedSpace
  from orion.core.worker.trial import Trial
  from orion.testing.algo import BaseAlgoTests, TestPhase
label_desc: Use image node_id 5 for calling the TestGenericPBT obj's underlying member method code with example usage: obj.assert_callbacks(spy, num, algo) without return types