class_docstr: TorchOptim wraps a torch optimizer for distributed inference or training.
docstr: :param optim: Pytorch optimizer or LrScheduler.
  :param decayType: one string of EpochDecay, IterationDecay, EpochDecayByScore if
                    the optim is LrScheduler.
                    EpochDecay: call LrScheduler.step() every epoch.
                    IterationDecay: call LrScheduler.step() every iteration.
                    EpochDecayByScore: call LrScheduler.step(val_score) every epoch,
                        val_score is the return value of the first validation method.
                        ReduceLROnPlateau must use this EpochDecayByScore.
code: def from_pytorch(optim, decayType="EpochDecay"):
      """
      :param optim: Pytorch optimizer or LrScheduler.
      :param decayType: one string of EpochDecay, IterationDecay, EpochDecayByScore if
                        the optim is LrScheduler.
                        EpochDecay: call LrScheduler.step() every epoch.
                        IterationDecay: call LrScheduler.step() every iteration.
                        EpochDecayByScore: call LrScheduler.step(val_score) every epoch,
                            val_score is the return value of the first validation method.
                            ReduceLROnPlateau must use this EpochDecayByScore.
      """
      bys = io.BytesIO()
      torch.save(optim, bys, pickle_module=zoo_pickle_module)
      zoo_optim = TorchOptim(bys.getvalue(), decayType)
      return zoo_optim
  
file_path: analytics-zoo/pyzoo/zoo/pipeline/api/torch/torch_optim.py
imports: import sys
  import io
  import torch
  from importlib.util import find_spec
  from zoo.pipeline.api.torch import zoo_pickle_module
  from bigdl.optim.optimizer import OptimMethod
label_desc: Use image node_id 2 for calling the TorchOptim obj's underlying member method code with example usage: obj.from_pytorch(optim, decayType) and returns: zoo_optim