class_docstr: Model of BFloat16 with auto mixed precision.
class_docstr_tok: ["Model","of","BFloat16","with","auto","mixed","precision","."]
docstr: This is the accelerated model for BFloat16 with auto mixed precision.
  
  :param model: the model(nn.module) to be transform.
  :param channels_last: if set model and data to be channels-last mode.
  :param channels_last_available: only passed by _load method,
         to decide which input can be converted to channels-last mode.
  :param thread_num: the thread num allocated for this model.
docstr_tok: ["This","is","the","accelerated","model","for","BFloat16","with","auto","mixed","precision",".",":","param","model",":","the","model","(","nn.module",")","to","be","transform",".",":","param","channels_last",":","if","set","model","and","data","to","be","channels-last","mode",".",":","param","channels_last_available",":","only","passed","by","_load","method",",","to","decide","which","input","can","be","converted","to","channels-last","mode",".",":","param","thread_num",":","the","thread","num","allocated","for","this","model","."]
code: def __init__(
      self,
      model,
      input_sample=None,
      channels_last=None,
      channels_last_available=[],
      thread_num=None,
      compression="fp32",
  ):  # noqa
      """
      This is the accelerated model for BFloat16 with auto mixed precision.
  
      :param model: the model(nn.module) to be transform.
      :param channels_last: if set model and data to be channels-last mode.
      :param channels_last_available: only passed by _load method,
             to decide which input can be converted to channels-last mode.
      :param thread_num: the thread num allocated for this model.
      """
      super().__init__(model)
      self._bf16_check()
      self.model = (
          model  # use mixed precision instead of complete precision
      )
      self.channels_last = channels_last
      self.thread_num = thread_num
      self.compression = compression
      if self.channels_last is True:
          try:
              self.model = self.model.to(
                  memory_format=torch.channels_last
              )
          except Exception as _e:
              self.model = self.model.to(
                  memory_format=torch.channels_last_3d
              )
          if channels_last_available:  # init from load
              self.channels_last_available = channels_last_available
          else:  # init without channels_last_available loaded
              self.channels_last_available = (
                  generate_channels_last_available(input_sample)
              )
      else:
          self.channels_last_available = []
  
      self._nano_context_manager = generate_context_manager(
          accelerator=None, precision="bf16", thread_num=thread_num
      )
  
imports: from logging import warning
  import torch
  import os
  from contextlib import redirect_stdout
  from bigdl.nano.utils.pytorch import generate_channels_last_available, apply_proper_channels_last
  from bigdl.nano.pytorch.model import AcceleratedLightningModule
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_1_10, TORCH_VERSION_LESS_1_12, transform_state_dict_to_dtype
  from bigdl.nano.utils.common import _bf16_checker
  from bigdl.nano.pytorch.context_manager import generate_context_manager
label_desc: Use image node_id 1 to create a new BF16Model object from inherited base classes: AcceleratedLightningModule with example: obj = BF16Model(model, input_sample, channels_last, channels_last_available, thread_num, compression)