code: def test_log_epoch_and_batch(self):
      with patch("poutyne.framework.wandb_logger.wandb") as wandb_patch:
          train_gen = some_data_generator(20)
          valid_gen = some_data_generator(20)
          wandb_patch.init = self.initialize_experiment
          wandb_patch.run = None
          num_batchs = 5
          logger = WandBLogger(
              name=self.a_name,
              log_gradient_frequency=1,
              batch_granularity=True,
          )
          history = History()
          self.model.fit_generator(
              train_gen,
              valid_gen,
              epochs=self.num_epochs,
              steps_per_epoch=num_batchs,
              callbacks=[logger, history],
          )
          experiment_call = []
          for is_epoch, log in history.history:
              if is_epoch:
                  train_metrics = {
                      key: value
                      for (key, value) in log.items()
                      if not key.startswith("val_")
                  }
                  train_metrics = {"training": {"epoch": train_metrics}}
  
                  experiment_call.append(call.log(train_metrics))
                  val_metrics = {
                      key[4:]: value
                      for (key, value) in log.items()
                      if key.startswith("val_")
                  }
                  val_metrics = {"validation": {"epoch": val_metrics}}
  
                  experiment_call.append(call(val_metrics))
  
                  experiment_call.append(
                      call({"params": {"lr": self.a_lr}})
                  )
              else:
                  train_metrics = {
                      key: value
                      for (key, value) in log.items()
                      if not key.startswith("val_")
                  }
                  train_metrics = {"training": {"batch": train_metrics}}
                  experiment_call.append(call(train_metrics))
  
          logger.run.log.assert_has_calls(
              experiment_call, any_order=False
          )
  
imports: import os
  import warnings
  from tempfile import TemporaryDirectory, TemporaryFile
  from unittest import TestCase, main, skipIf
  from unittest.mock import MagicMock, call, patch
  import torch
  import torch.nn
  from poutyne import Callback, Model, ModelCheckpoint, WandBLogger
  from tests.framework.tools import some_data_generator
label_desc: Use image node_id 12 for calling the WandBLoggerTest obj's underlying member method code with example usage: obj.test_log_epoch_and_batch() without return types