code: def test_trainer_disable_tb_logging(
      self,
      monkeypatch: monkeypatch.MonkeyPatch,
      tmp_path: pathlib.Path,
      enable_tensorboard_logging: bool,
  ):
      # there is no direct way to set tensorboard path in Trainer API
      def mock_get_tensorboard_path(
          dummy: typing.Dict[str, typing.Any]
      ) -> pathlib.Path:
          return tmp_path.joinpath("tensorboard")
  
      monkeypatch.setattr(
          pytorch.PyTorchTrialContext,
          "get_tensorboard_path",
          mock_get_tensorboard_path,
      )
  
      checkpoint_batches = 5
      validation_batches = 5
  
      with mock.patch.object(
          det.pytorch, "_log_tb_metrics", return_value=None
      ) as mock_method:
          with pytorch.init(
              hparams=self.hparams,
              enable_tensorboard_logging=enable_tensorboard_logging,
          ) as train_context:
              trial = pytorch_onevar_model.OneVarTrialCallbacks(
                  train_context
              )
              trainer = pytorch.Trainer(trial, train_context)
              trainer.fit(
                  max_length=pytorch.Epoch(1),
                  checkpoint_period=pytorch.Batch(checkpoint_batches),
                  validation_period=pytorch.Batch(validation_batches),
              )
          if enable_tensorboard_logging:
              assert mock_method.call_count > 0
          else:
              assert mock_method.call_count == 0
  
imports: import contextlib
  import importlib
  import io
  import os
  import pathlib
  import sys
  import typing
  from unittest import mock
  import numpy
  import pytest
  import torch
  from _pytest import monkeypatch
  from torch.distributed import launcher
  import determined
  from determined import pytorch
  from tests.experiment import pytorch_utils, utils
  from tests.experiment.fixtures import pytorch_onevar_model
label_desc: Use image node_id 26 for calling the TestPyTorchTrial obj's underlying member method code with example usage: obj.test_trainer_disable_tb_logging(monkeypatch, tmp_path, enable_tensorboard_logging) and returns: tmp_path