code: def to_channelslast(
      self: Learner,
      use_amp: bool = True,  # Add `MixedPrecision` with `amp_mode`. Recommended for full channels last performance
      amp_mode: str
      | AMPMode = AMPMode.FP16,  # Mixed Precision training mode. Supports fp16 and bf16.
      **kwargs,
  ):
      "Set `Learner` and inputs to `channels_last` format and float16 Mixed Precision by default"
      if (
          use_amp
          and not hasattr(self, "mixed_precision")
          and not hasattr(self, "channels_last")
      ):
          return self.add_cbs(
              [ChannelsLast(), MixedPrecision(amp_mode, **kwargs)]
          )
      elif not hasattr(self, "channels_last"):
          return self.add_cb(ChannelsLast())
  
file_path: fastai/fastai/callback/channelslast.py
imports: from __future__ import annotations
  from ..basics import *
  from .fp16 import AMPMode, MixedPrecision
  from torch.cuda.amp import GradScaler
label_desc: Use image node_id 1 for calling a global function with example usage: to_channelslast(use_amp, amp_mode) and returns: self, self