code: def serialize(cls, *args, **kwargs):
      """
      To create an serializable instance inline without decorator. For example,
  
      .. code-block:: python
  
          self.op = serialize(MyCustomOp, hidden_units=128)
      """
      warnings.warn(
          "nni.retiarii.serialize is deprecated and will be removed in future release. "
          + "Try to use nni.trace, e.g., nni.trace(torch.optim.Adam)(learning_rate=1e-4) instead.",
          category=DeprecationWarning,
      )
      return trace(cls)(*args, **kwargs)
  
file_path: nni/nni/nas/utils/_legacy.py
imports: import inspect
  import os
  import warnings
  from typing import Any, TypeVar, Type
  from nni.common.serializer import is_traceable, is_wrapped_with_trace, trace
label_desc: Use image node_id 2 for calling a global function with example usage: serialize(cls) and returns: trace