class_docstr: Custom pl.Callback for converting model and data to channels_last.
docstr: Override hook setup to convert model to channels_last and wrap DataHook.
code: def setup(
      self, trainer, pl_module, stage: Optional[str] = None
  ) -> None:
      """Override hook setup to convert model to channels_last and wrap DataHook."""
      # TODO: Add check for module_states
      try:
          pl_module = pl_module.to(memory_format=torch.channels_last)
      except Exception as e:
          warning(
              f"Convert model to channels last failed, \
                      fall back to origin memory format. Exception msg: {e}"
          )
          return super().setup(trainer, pl_module, stage)
      fn_old = getattr(pl_module, "on_before_batch_transfer")
      fn = batch_call(fn_old)
      setattr(pl_module, "on_before_batch_transfer_origin", fn_old)
      pl_module.on_before_batch_transfer = MethodType(fn, pl_module)
      return super().setup(trainer, pl_module, stage)
  
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 1 for calling the ChannelsLastCallback obj's underlying member method code with example usage: obj.setup(trainer, pl_module, stage) and returns: super, super