parameters: (module, destination, prefix, local_metadata)
docstring: Hook to add ShardedTensor to Module's ``state_dict``. Needs to be
      registered to the Module using
      :meth:`torch.nn.Module._register_state_dict_hook`.
docstring_summary: Hook to add ShardedTensor to Module's ``state_dict``. Needs to be
      registered to the Module using
      :meth:`torch.nn.Module._register_state_dict_hook`.
docstring_tokens: Hook to add ShardedTensor to Module s state_dict . Needs to be registered to the Module using : meth : torch . nn . Module . _register_state_dict_hook .
function: def state_dict_hook(module, destination, prefix, local_metadata):
      """
      Hook to add ShardedTensor to Module's ``state_dict``. Needs to be
      registered to the Module using
      :meth:`torch.nn.Module._register_state_dict_hook`.
      """
      for submodule_name, submodule in module.named_modules():
          for attr_name, attr in submodule.__dict__.items():
              if isinstance(attr, ShardedTensor):
                  destination[prefix + submodule_name + '.' + attr_name] = attr
function_tokens: def state_dict_hook ( module , destination , prefix , local_metadata ) : for submodule_name , submodule in module . named_modules ( ) : for attr_name , attr in submodule . __dict__ . items ( ) : if isinstance ( attr , ShardedTensor ) : destination [ prefix + submodule_name + '.' + attr_name ] = attr