class_docstr: A wrapper class for model to cast the model into fp16 and
  automatically cast the input and output
  
  Args:
      model (torch.nn.Module): torch.nn.Module to be wrapped.
      output_to_fp32 (bool, optional): Whether cast output of this module into fp32. (Default: True)
      parallel_mode (:class:`colossalai.legacy.context.ParallelMode`): Parallel group mode used in this module.
                                                                (Default: ``ParallelMode.DATA``)
      sync_buffer (bool, optional): whether to synchronize buffer. (Default: True)
  
  Note:
      The parallel_mode should be concluded in ``ParallelMode``. More details about ``ParallelMode`` could be found
      in `parallel_mode <https://github.com/hpcaitech/ColossalAI/blob/main/colossalai/context/parallel_mode.py>`_.
class_docstr_tok: ["A","wrapper","class","for","model","to","cast","the","model","into","fp16","and","automatically","cast","the","input","and","output","Args",":","model","(","torch.nn.Module",")",":","torch.nn.Module","to","be","wrapped",".","output_to_fp32","(","bool",",","optional",")",":","Whether","cast","output","of","this","module","into","fp32",".","(","Default",":","True",")","parallel_mode","(",":","class",":","`","colossalai.legacy.context.ParallelMode","`",")",":","Parallel","group","mode","used","in","this","module",".","(","Default",":","``","ParallelMode.DATA","``",")","sync_buffer","(","bool",",","optional",")",":","whether","to","synchronize","buffer",".","(","Default",":","True",")","Note",":","The","parallel_mode","should","be","concluded","in","``","ParallelMode","``",".","More","details","about","``","ParallelMode","``","could","be","found","in","`","parallel_mode","<","https",":","\/\/github.com\/hpcaitech\/ColossalAI\/blob\/main\/colossalai\/context\/parallel_mode.py",">","`","_","."]
code: def _convert_to_fp16(self, input_: Any):
      if isinstance(input_, Tensor) and input_.dtype == torch.float32:
          input_ = input_.half()
      return input_
  
imports: from typing import Any
  import torch
  import torch.distributed
  import torch.nn
  from torch import Tensor
  from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
  from torch.distributed import ReduceOp
  from torch.optim import Optimizer
  from colossalai.interface import OptimizerWrapper
  from colossalai.legacy.context import ParallelMode
  from colossalai.legacy.core import global_context
  from ._fp16_optimizer import FP16Optimizer
label_desc: Use image node_id 4 for calling the NaiveAMPModel obj's underlying member method code with example usage: obj._convert_to_fp16(input_) and returns: input_