class_docstr: Tests parameter flattening and shard metadata logic.
docstr: Tests the subroutine ``_get_shard_metadata()`` that computes shard
  metadata based on start and end indices in the unsharded flat
  parameter, where both indices are inclusive.
  
  We manually set the relevant attributes on the flat parameter to be
  able to check the effect of ``_get_shard_metadata()`` via
  ``shard_metadata()`` since normally the attributes are set in
  ``_init_shard_metadata()`` with the start and end indices fixed based
  on rank and world size.
code: def _test_flat_param_shard_metadata(
      self,
      handle: FlatParamHandle,
      start: int,
      end: int,
      expected: FlatParamShardMetadata,
  ):
      """
      Tests the subroutine ``_get_shard_metadata()`` that computes shard
      metadata based on start and end indices in the unsharded flat
      parameter, where both indices are inclusive.
  
      We manually set the relevant attributes on the flat parameter to be
      able to check the effect of ``_get_shard_metadata()`` via
      ``shard_metadata()`` since normally the attributes are set in
      ``_init_shard_metadata()`` with the start and end indices fixed based
      on rank and world size.
      """
      flat_param = handle.flat_param
      flat_param._shard_param_infos = handle._get_shard_metadata(
          start, end
      )
      shard_metadata = handle.shard_metadata()
      self.assertEqual(
          shard_metadata,
          expected,
          msg=f"{handle.shard_metadata()}, {expected}",
      )
  
imports: import sys
  import torch
  import torch.nn
  from torch import distributed
  from torch.distributed.fsdp import FullyShardedDataParallel
  from torch.distributed.fsdp._flat_param import FlatParamHandle, FlatParamShardMetadata, HandleShardingStrategy
  from torch.testing._internal.common_distributed import skip_if_lt_x_gpu
  from torch.testing._internal.common_fsdp import FSDPTest
  from torch.testing._internal.common_utils import run_tests, TEST_WITH_DEV_DBG_ASAN
label_desc: Use image node_id 28 for calling the TestFlattenParams obj's underlying member method code with example usage: obj._test_flat_param_shard_metadata(handle, start, end, expected) without return types