code: def batch_call(func):
      """
      Decorator to extending hook of pl_module.
  
      Extending behavior hook on_before_batch_transfer to convert data to channels_last
      for each batch.
      """
  
      def on_before_batch_transfer(self, batch, dataloader_idx):
          def convert_channels_last(batch):
              if isinstance(batch, torch.Tensor) and batch.dim() == 4:
                  batch = batch.to(memory_format=torch.channels_last)
              elif isinstance(batch, list) or isinstance(batch, tuple):
                  batch = list(batch)
                  for index, t in enumerate(batch):
                      batch[index] = convert_channels_last(t)
              return batch
  
          batch = func(batch, dataloader_idx)
          batch = convert_channels_last(batch)
          return batch
  
      return on_before_batch_transfer
  
file_path: BigDL/python/nano/src/bigdl/nano/utils/pytorch/channel_last.py
imports: from typing import Optional
  from types import MethodType
  from logging import warning
  import torch
  import pytorch_lightning
label_desc: Use image node_id 3 for calling a global function with example usage: batch_call(func) and returns: on_before_batch_transfer, batch, batch