docstr: Test fit entry point with evaluate_every_n_steps=5
docstr_tok: ["Test","fit","entry","point","with","evaluate_every_n_steps=5"]
code: def test_fit_evaluate_every_n_steps(self) -> None:
      """
      Test fit entry point with evaluate_every_n_steps=5
      """
      input_dim = 2
      train_dataset_len = 16
      eval_dataset_len = 4
      batch_size = 2
      max_epochs = 3
      evaluate_every_n_steps = 5
      expected_train_steps_per_epoch = train_dataset_len / batch_size
      expected_total_train_steps = (
          expected_train_steps_per_epoch * max_epochs
      )
      expected_eval_steps_per_epoch = eval_dataset_len / batch_size
      expected_num_evaluate_calls = math.floor(
          expected_total_train_steps / evaluate_every_n_steps
      )
  
      my_unit = DummyFitUnit(input_dim=input_dim)
  
      train_dataloader = generate_random_dataloader(
          train_dataset_len, input_dim, batch_size
      )
      eval_dataloader = generate_random_dataloader(
          eval_dataset_len, input_dim, batch_size
      )
  
      fit(
          my_unit,
          train_dataloader=train_dataloader,
          eval_dataloader=eval_dataloader,
          max_epochs=max_epochs,
          evaluate_every_n_epochs=None,
          evaluate_every_n_steps=evaluate_every_n_steps,
      )
  
      self.assertEqual(
          my_unit.train_progress.num_epochs_completed, max_epochs
      )
      self.assertEqual(
          my_unit.train_progress.num_steps_completed_in_epoch, 0
      )
      self.assertEqual(
          my_unit.train_progress.num_steps_completed,
          max_epochs * expected_train_steps_per_epoch,
      )
  
      self.assertEqual(
          my_unit.eval_progress.num_epochs_completed,
          expected_num_evaluate_calls,
      )
      self.assertEqual(
          my_unit.eval_progress.num_steps_completed_in_epoch, 0
      )
      self.assertEqual(
          my_unit.eval_progress.num_steps_completed,
          expected_num_evaluate_calls * expected_eval_steps_per_epoch,
      )
  
imports: import math
  import unittest
  from typing import Tuple
  from unittest.mock import MagicMock
  import torch
  from torch import nn
  from torchtnt.framework._test_utils import DummyFitUnit, generate_random_dataloader
  from torchtnt.framework.callback import Callback
  from torchtnt.framework.fit import fit
  from torchtnt.framework.state import ActivePhase, State
  from torchtnt.framework.unit import EvalUnit, TrainUnit, TTrainUnit
  from torchtnt.utils.timer import Timer
label_desc: Use image node_id 2 for calling the FitTest obj's underlying member method code with example usage: obj.test_fit_evaluate_every_n_steps() without return types