def test_profiler_table_kwargs_summary_length(tmp_path):
    """Test if setting max_name_column_width in table_kwargs changes table width."""

    summaries = []
    # Default table_kwargs (None) sets max_name_column_width to 55
    for table_kwargs in [{"max_name_column_width": 1}, {"max_name_column_width": 5}, None]:
        pytorch_profiler = PyTorchProfiler(
            dirpath=tmp_path, filename="profile", schedule=None, table_kwargs=table_kwargs
        )

        with pytorch_profiler.profile("a"):
            torch.ones(1)
        pytorch_profiler.describe()
        summaries.append(pytorch_profiler.summary())

    # Check if setting max_name_column_width results in a wider table (more dashes)
    assert summaries[0].count("-") < summaries[1].count("-")
    assert summaries[1].count("-") < summaries[2].count("-")
Test if setting max_name_column_width in table_kwargs changes table width.
tests/tests_pytorch/profilers/test_profiler.py