class_docstr: DeepSpeed engine for training and inference.
class_docstr_tok: ["DeepSpeed","engine","for","training","and","inference","."]
code: def convert_to_linear_transposed(self, model):
      def _replace_linear_layer(
          r_module, parent_type=None, prev_type=None
      ):
          for name, child in r_module.named_children():
              if child.__class__ in [torch.nn.Linear] and (
                  parent_type is torch.nn.ModuleList
                  or prev_type is torch.nn.ModuleList
              ):
                  setattr(r_module, name, TLinear(child, name))
              else:
                  _replace_linear_layer(
                      child, type(r_module), prev_type=parent_type
                  )
          return r_module
  
      _replace_linear_layer(model)
  
imports: import torch
  from deepspeed.inference.config import DeepSpeedInferenceConfig
  from deepspeed.module_inject.replace_policy import replace_policies
  from deepspeed.module_inject.utils import policy_to_ds_container
  from .engine import DeepSpeedEngine
  from .utils import TLinear, get_inactive_params
  from deepspeed.runtime.zero import GatheredParameters
  import time
  import gc
  import math
  from deepspeed import comm
  from deepspeed.accelerator import get_accelerator
  from torch import nn
  from deepspeed.utils import logger
  from deepspeed.ops.op_builder import InferenceBuilder
  from deepspeed.module_inject.layers import LinearLayer, Normalize, EmbeddingLayer, OPTEmbedding
label_desc: Use image node_id 2 for calling the DeepSpeedHybridEngine obj's underlying member method code with example usage: obj.convert_to_linear_transposed(model) and returns: r_module