code: def module_policy(self):
      from transformers.models.gptj.modeling_gptj import (
          GPTJAttention,
          GPTJBlock,
          GPTJModel,
      )
  
      policy = {}
      if self.shard_config.enable_sequence_parallelism:
          self.shard_config.enable_sequence_parallelism = False
          warnings.warn(
              "GPTJ doesn't support sequence parallelism now, will ignore the sequence parallelism flag."
          )
      use_sequence_parallel = (
          self.shard_config.enable_sequence_parallelism
      )
  
      overlap = self.shard_config.enable_sequence_overlap
      if self.shard_config.enable_tensor_parallelism:
          policy[GPTJModel] = ModulePolicyDescription(
              sub_module_replacement=[
                  SubModuleReplacementDescription(
                      suffix="wte",
                      target_module=col_nn.VocabParallelEmbedding1D,
                  ),
                  SubModuleReplacementDescription(
                      suffix="drop",
                      target_module=col_nn.DropoutForParallelInput,
                  ),
              ]
          )
  
          policy[GPTJBlock] = ModulePolicyDescription(
              attribute_replacement={
                  "attn.embed_dim": self.model.config.hidden_size
                  // self.shard_config.tensor_parallel_size,
                  "attn.num_attention_heads": self.model.config.num_attention_heads
                  // self.shard_config.tensor_parallel_size,
              },
              sub_module_replacement=[
                  SubModuleReplacementDescription(
                      suffix="attn.k_proj",
                      target_module=col_nn.Linear1D_Col,
                      kwargs={
                          "seq_parallel": use_sequence_parallel,
                          "overlap": overlap,
                      },
                  ),
                  SubModuleReplacementDescription(
                      suffix="attn.q_proj",
                      target_module=col_nn.Linear1D_Col,
                      kwargs={
                          "seq_parallel": use_sequence_parallel,
                          "overlap": overlap,
                      },
                  ),
                  SubModuleReplacementDescription(
                      suffix="attn.v_proj",
                      target_module=col_nn.Linear1D_Col,
                      kwargs={
                          "seq_parallel": use_sequence_parallel,
                          "overlap": overlap,
                      },
                  ),
                  SubModuleReplacementDescription(
                      suffix="attn.out_proj",
                      target_module=col_nn.Linear1D_Row,
                      kwargs={"seq_parallel": use_sequence_parallel},
                  ),
                  SubModuleReplacementDescription(
                      suffix="mlp.fc_in",
                      target_module=col_nn.Linear1D_Col,
                      kwargs={"seq_parallel": use_sequence_parallel},
                  ),
                  SubModuleReplacementDescription(
                      suffix="mlp.fc_out",
                      target_module=col_nn.Linear1D_Row,
                      kwargs={"seq_parallel": use_sequence_parallel},
                  ),
                  SubModuleReplacementDescription(
                      suffix="attn.attn_dropout",
                      target_module=col_nn.DropoutForParallelInput,
                  ),
                  SubModuleReplacementDescription(
                      suffix="attn.resid_dropout",
                      target_module=col_nn.DropoutForParallelInput,
                  ),
                  SubModuleReplacementDescription(
                      suffix="mlp.dropout",
                      target_module=col_nn.DropoutForParallelInput,
                  ),
              ],
          )
  
      # optimization configuration
      if self.shard_config.enable_fused_normalization:
          self.append_or_create_submodule_replacement(
              description=SubModuleReplacementDescription(
                  suffix="ln_f",
                  target_module=col_nn.FusedLayerNorm,
              ),
              policy=policy,
              target_key=GPTJModel,
          )
  
          self.append_or_create_submodule_replacement(
              description=[
                  SubModuleReplacementDescription(
                      suffix="ln_1",
                      target_module=col_nn.FusedLayerNorm,
                  )
              ],
              policy=policy,
              target_key=GPTJBlock,
          )
  
      if self.shard_config.enable_flash_attention:
          self.append_or_create_method_replacement(
              description={
                  "forward": get_gptj_flash_attention_forward(),
              },
              policy=policy,
              target_key=GPTJAttention,
          )
  
      return policy
  
imports: import warnings
  from functools import partial
  from typing import Callable, Dict, List
  from torch import Tensor, nn
  import colossalai.shardformer.layer
  from ..modeling.gptj import GPTJPipelineForwards, get_gptj_flash_attention_forward
  from .base_policy import ModulePolicyDescription, Policy, SubModuleReplacementDescription
label_desc: Use image node_id 3 for calling the GPTJPolicy obj's underlying member method code with example usage: obj.module_policy() and returns: policy