code: def test_log_api_call_count(wandb: mock.MagicMock) -> None:
      wandb.sdk.wandb_run.Run = mock.MagicMock
  
      study = optuna.create_study()
      wandbc = WeightsAndBiasesCallback()
  
      @wandbc.track_in_wandb()
      def _decorated_objective(trial: optuna.trial.Trial) -> float:
          result = _objective_func(trial)
          wandb.run.log({"result": result})
          return result
  
      target_n_trials = 10
      study.optimize(
          _objective_func, n_trials=target_n_trials, callbacks=[wandbc]
      )
      assert wandb.run.log.call_count == target_n_trials
  
      wandbc = WeightsAndBiasesCallback(as_multirun=True)
      wandb.run.reset_mock()
  
      study.optimize(
          _decorated_objective,
          n_trials=target_n_trials,
          callbacks=[wandbc],
      )
  
      assert wandb.run.log.call_count == 2 * target_n_trials
  
      wandb.run = None
      study.optimize(
          _objective_func, n_trials=target_n_trials, callbacks=[wandbc]
      )
      assert wandb.init().log.call_count == target_n_trials
  
imports: from typing import Any
  from typing import Dict
  from typing import List
  from typing import Sequence
  from typing import Tuple
  from typing import Union
  from unittest import mock
  import pytest
  import optuna
  from optuna.integration import WeightsAndBiasesCallback
label_desc: Use image node_id 6 for calling a global function with example usage: test_log_api_call_count(wandb) and returns: result