class_docstr: Replace original Huggingface's layer into Megatron tensor sliced layer.
  
  Args:
      model (nn.Module): Huggingface pre-trained transformer model
      mp_group (Any): process group for model parallelism
      fp16: (bool): Whether use FP16 or not.
      num_gpus (int): number of GPUs
      custom_policies (Union[Policy, List[Policy]]): custom policy object (default=None)
class_docstr_tok: ["Replace","original","Huggingface","'s","layer","into","Megatron","tensor","sliced","layer",".","Args",":","model","(","nn.Module",")",":","Huggingface","pre-trained","transformer","model","mp_group","(","Any",")",":","process","group","for","model","parallelism","fp16",":","(","bool",")",":","Whether","use","FP16","or","not",".","num_gpus","(","int",")",":","number","of","GPUs","custom_policies","(","Union","[","Policy",",","List","[","Policy","]","]",")",":","custom","policy","object","(","default=None",")"]
docstr: Apply resize layer size to original layer object
  
  Args:
      policy (Policy): policy object
      name (str): name of parameters
      size (Size): size of resized parameters
docstr_tok: ["Apply","resize","layer","size","to","original","layer","object","Args",":","policy","(","Policy",")",":","policy","object","name","(","str",")",":","name","of","parameters","size","(","Size",")",":","size","of","resized","parameters"]
code: def set_layer_size(
      policy: Policy,
      name: str,
      size: Size,
  ) -> None:
      """
      Apply resize layer size to original layer object
  
      Args:
          policy (Policy): policy object
          name (str): name of parameters
          size (Size): size of resized parameters
      """
      layer_name = ".".join(f"{name}".split(".")[:-1])
      if rhasattr(policy, f"{layer_name}.nf"):
          rsetattr(
              policy,
              f"{layer_name}.nf",
              size[1],
          )
      else:
          for name in ["channels", "features"]:
              if name == "channels":
                  direction = ["in", "out"]
              else:
                  direction = ["out", "in"]
              for i, direction in enumerate(direction):
                  if rhasattr(
                      policy, f"{layer_name}.{direction}_{name}"
                  ):
                      rsetattr(
                          policy,
                          f"{layer_name}.{direction}_{name}",
                          size[i],
                      )
  
file_path: parallelformers/parallelformers/parallel/replacing.py
imports: from contextlib import suppress
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, Union
  import torch.nn
  from torch import Size, Tensor
  from parallelformers.parallel.slicing import TensorSlicer
  from parallelformers.policies.base import Layer, Policy
  from parallelformers.policies.base.auto import AutoPolicy
  from parallelformers.utils import rgetattr, rhasattr, rsetattr
label_desc: Use image node_id 8 for calling the TensorReplacer obj's underlying member method code with example usage: obj.set_layer_size(policy, name, size) without return types