code: def inject_model_parallel_rank(filepath, fsdp_sharded_ckpt=False):
      """
      Injects tensor/pipeline model parallel ranks into the filepath.
      Does nothing if not using model parallelism.
      """
      # first make sure filepath does not have rank
      filepath = uninject_model_parallel_rank(filepath)
  
      app_state = AppState()
      dirname = os.path.dirname(filepath)
      basename = os.path.basename(filepath)
      if (
          app_state.model_parallel_size is not None
          and app_state.model_parallel_size > 1
      ):
          fsdp_shard = (
              f"_fsdp_shard_{app_state.data_parallel_rank:05d}"
              if fsdp_sharded_ckpt
              else ""
          )
          if (
              app_state.pipeline_model_parallel_size is None
              or app_state.pipeline_model_parallel_size == 1
          ):
              filepath = f"{dirname}/mp_rank_{app_state.tensor_model_parallel_rank:02d}{fsdp_shard}/{basename}"
          else:
              filepath = f"{dirname}/tp_rank_{app_state.tensor_model_parallel_rank:02d}_pp_rank_{app_state.pipeline_model_parallel_rank:03d}/{basename}"
          return filepath
      else:
          fsdp_shard = (
              f"/fsdp_shard_{app_state.data_parallel_rank:05d}"
              if fsdp_sharded_ckpt
              else ""
          )
          return f"{dirname}{fsdp_shard}/{basename}"
  
imports: import copy
  import importlib
  import os
  from dataclasses import dataclass, is_dataclass
  from enum import Enum
  from functools import lru_cache
  from pathlib import Path
  from typing import List, Optional, Tuple, Union
  import wrapt
  from nemo.utils import AppState, logging
  from nemo.utils.data_utils import resolve_cache_dir
  from nemo.utils.data_utils import is_datastore_path
label_desc: Use image node_id 14 for calling a global function with example usage: inject_model_parallel_rank(filepath, fsdp_sharded_ckpt) and returns: filepath, dirname, fsdp_shard, str, basename