docstr: Test GarbageCollector callback was called correct number of times (with fit entry point)
docstr_tok: ["Test","GarbageCollector","callback","was","called","correct","number","of","times","(","with","fit","entry","point",")"]
code: def test_garbage_collector_call_count_fit(self) -> None:
      """
      Test GarbageCollector callback was called correct number of times (with fit entry point)
      """
      input_dim = 2
      train_dataset_len = 10
      eval_dataset_len = 6
      batch_size = 2
      max_epochs = 2
      evaluate_every_n_epochs = 1
      expected_num_total_steps = (
          train_dataset_len / batch_size * max_epochs
          + eval_dataset_len / batch_size * max_epochs
      )
      gc_step_interval = 4
  
      my_unit = DummyFitUnit(2)
      gc_callback = GarbageCollector(gc_step_interval)
  
      train_dataloader = generate_random_dataloader(
          train_dataset_len, input_dim, batch_size
      )
      eval_dataloader = generate_random_dataloader(
          eval_dataset_len, input_dim, batch_size
      )
  
      # we call gc.collect() once for every step with generation=1, and then we call gc.collect()
      expected_num_calls_to_gc_collect = (
          expected_num_total_steps
          + expected_num_total_steps / gc_step_interval
      )
      with mock.patch(
          "torchtnt.framework.callbacks.garbage_collector.gc.collect"
      ) as gc_collect_mock:
          fit(
              my_unit,
              train_dataloader=train_dataloader,
              eval_dataloader=eval_dataloader,
              max_epochs=max_epochs,
              evaluate_every_n_epochs=evaluate_every_n_epochs,
              callbacks=[gc_callback],
          )
          self.assertEqual(
              gc_collect_mock.call_count,
              expected_num_calls_to_gc_collect,
          )
  
imports: import gc
  import unittest
  from unittest import mock
  from unittest.mock import MagicMock
  from torchtnt.framework._test_utils import DummyEvalUnit, DummyFitUnit, DummyPredictUnit, DummyTrainUnit, generate_random_dataloader
  from torchtnt.framework.callbacks.garbage_collector import GarbageCollector
  from torchtnt.framework.evaluate import evaluate
  from torchtnt.framework.fit import fit
  from torchtnt.framework.predict import predict
  from torchtnt.framework.train import train
label_desc: Use image node_id 7 for calling the GarbageCollectorTest obj's underlying member method code with example usage: obj.test_garbage_collector_call_count_fit() without return types