code: def test_inf_gradients_skip_optim_step(self):
      pg = DummyProcessGroup(0, 1)
      scaler = ShardedGradScaler(
          init_scale=2.0, process_group=pg, enabled=True
      )
      loss = torch.full((1,), 4.0, dtype=torch.float32, device="cpu")
      t0 = torch.tensor(
          [float("inf")], dtype=torch.float32, device="cpu"
      )
      t0.grad = t0.clone()
      opt = torch.optim.SGD([t0], lr=1.0)
      scaler.scale(loss)
      ret_val = scaler.step(opt)
      self.assertTrue(ret_val is None)
  
imports: import copy
  import functools
  import itertools
  import sys
  import unittest
  from typing import List, Optional
  import torch
  from torch import distributed
  from torch.cuda.amp.common import amp_definitely_not_available
  from torch.distributed.fsdp import CPUOffload, MixedPrecision
  from torch.distributed.fsdp.fully_sharded_data_parallel import FullyShardedDataParallel, ShardingStrategy
  from torch.distributed.fsdp.sharded_grad_scaler import ShardedGradScaler
  from torch.distributed.fsdp.wrap import ModuleWrapPolicy
  from torch.nn import TransformerDecoderLayer, TransformerEncoderLayer
  from torch.nn.parallel.distributed import DistributedDataParallel
  from torch.testing._internal.common_distributed import skip_if_lt_x_gpu
  from torch.testing._internal.common_fsdp import CUDAInitMode, DummyProcessGroup, FSDPInitMode, FSDPTest, NestedWrappedModule, NonUniformReqGradNWM, subtest_name, TransformerWithSharedParams
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, run_tests, TEST_WITH_DEV_DBG_ASAN, TestCase
label_desc: Use image node_id 3 for calling the TestShardGradScaler obj's underlying member method code with example usage: obj.test_inf_gradients_skip_optim_step() without return types