class_docstr: No grad context manager for Pytorch Model Inference.
  
  This context manager is used for providing no_grad context only.
class_docstr_tok: ["No","grad","context","manager","for","Pytorch","Model","Inference",".","This","context","manager","is","used","for","providing","no_grad","context","only","."]
code: def __enter__(self):
      if self.thread_num is not None:
          torch.set_num_threads(self.thread_num)
      if not hasattr(self, "infer_mode"):
          if self.infer_mode_string == "inference_mode":
              self.infer_mode = torch.inference_mode(mode=True)
          else:
              self.infer_mode = torch.no_grad()
      self.infer_mode.__enter__()
      if self.accelerator == "jit" and self.enable_onednn is True:
          if compare_version("torch", operator.ge, "1.12.0"):
              # onednn fusion be added to torch from version 1.12
              if not torch.jit.onednn_fusion_enabled():
                  torch.jit.enable_onednn_fusion(True)
  
imports: import torch
  import operator
  from bigdl.nano.utils.common import compare_version
label_desc: Use image node_id 2 for calling the BaseContextManager obj's underlying member method code with example usage: obj.__enter__() without return types