docstr: Test parameter validation.
docstr_tok: ["Test","parameter","validation","."]
code: def test_validation(self) -> None:
      """Test parameter validation."""
      with tempfile.TemporaryDirectory() as temp_dir:
          with self.assertRaisesRegex(
              ValueError, "start_step must be nonnegative."
          ):
              _ = MemorySnapshotProfiler(
                  output_dir=temp_dir,
                  memory_snapshot_params=MemorySnapshotParams(
                      start_step=-1, stop_step=0
                  ),
              )
          with self.assertRaisesRegex(
              ValueError,
              "stop_step must be specified when start_step is set.",
          ):
              _ = MemorySnapshotProfiler(
                  output_dir=temp_dir,
                  memory_snapshot_params=MemorySnapshotParams(
                      start_step=2, stop_step=None
                  ),
              )
          with self.assertRaisesRegex(
              ValueError, "start_step must be < stop_step."
          ):
              _ = MemorySnapshotProfiler(
                  output_dir=temp_dir,
                  memory_snapshot_params=MemorySnapshotParams(
                      start_step=2, stop_step=0
                  ),
              )
          with self.assertRaisesRegex(
              ValueError, "stop_step must be positive."
          ):
              _ = MemorySnapshotProfiler(
                  output_dir=temp_dir,
                  memory_snapshot_params=MemorySnapshotParams(
                      stop_step=0
                  ),
              )
          with self.assertRaisesRegex(
              ValueError,
              "stop_step must be enabled with either start_step or enable_oom_observer.",
          ):
              _ = MemorySnapshotProfiler(
                  output_dir=temp_dir,
                  memory_snapshot_params=MemorySnapshotParams(
                      stop_step=2, enable_oom_observer=False
                  ),
              )
          with self.assertRaisesRegex(
              ValueError,
              "At least one of start_step/stop_step or enable_oom_observer must be set.",
          ):
              _ = MemorySnapshotProfiler(
                  output_dir=temp_dir,
                  memory_snapshot_params=MemorySnapshotParams(
                      start_step=None,
                      stop_step=None,
                      enable_oom_observer=False,
                  ),
              )
  
file_path: tnt/tests/utils/test_memory_snapshot_profiler.py
imports: import os
  import tempfile
  import unittest
  import torch
  from torchtnt.utils.device import get_device_from_env
  from torchtnt.utils.memory_snapshot_profiler import MemorySnapshotParams, MemorySnapshotProfiler
  from torchtnt.utils.version import is_torch_version_geq_2_0
label_desc: Use image node_id 2 for calling the MemorySnapshotProfilerTest obj's underlying member method code with example usage: obj.test_validation() without return types