# torch 2.15.0 (BSD-3-Clause), harvested by tools/harvest_corpus.py
=== input
Patch the ``state_dict`` and ``load_state_dict`` attributes of ``optimizers``.

    Patch the ``state_dict`` and ``load_state_dict`` attributes of ``optimizers`` to
    be a partial function to call ``get_state_dict`` and ``set_state_dict``.

    Note that if there are multiple optimizers, all of the optimizers will be patched.
    So users only need to call one of the state_dict() to get the full result.

    Example:
        from torch.distributed.fsdp import FullyShardedDataParallel as FSDP
        from torch.distributed.checkpoint.state_dict import patch_model_state_dict

        model = fsdp(model)
        patch_model_state_dict(model)

    Args:
        model (nn.Module): the nn.Module to the model.
        options (StateDictOptions): the options to control how
            model state_dict and optimizer state_dict should be loaded. See
            `StateDictOptions` for the details.
    Returns:
        None
    
=== parse google
short_description: 'Patch the ``state_dict`` and ``load_state_dict`` attributes of ``optimizers``.'
long_description: |
  Patch the ``state_dict`` and ``load_state_dict`` attributes of ``optimizers`` to
  be a partial function to call ``get_state_dict`` and ``set_state_dict``.
  
  Note that if there are multiple optimizers, all of the optimizers will be patched.
  So users only need to call one of the state_dict() to get the full result.
blank_after_short_description: True
blank_after_long_description: True
style: google
- DocstringExample
  description: |
    from torch.distributed.fsdp import FullyShardedDataParallel as FSDP
    from torch.distributed.checkpoint.state_dict import patch_model_state_dict
    
    model = fsdp(model)
    patch_model_state_dict(model)
  kind: examples
  key: 'examples'
- DocstringParam
  description: 'the nn.Module to the model.'
  kind: param
  key: 'param'
  arg_name: 'model'
  type_name: 'nn.Module'
  is_optional: False
- DocstringParam
  description: |
    the options to control how
    model state_dict and optimizer state_dict should be loaded. See
    `StateDictOptions` for the details.
  kind: param
  key: 'param'
  arg_name: 'options'
  type_name: 'StateDictOptions'
  is_optional: False
- DocstringReturns
  description: 'None'
  kind: returns
  key: 'returns'
  is_generator: False
=== detect
google
=== compose google
Patch the ``state_dict`` and ``load_state_dict`` attributes of ``optimizers``.

Patch the ``state_dict`` and ``load_state_dict`` attributes of ``optimizers`` to
be a partial function to call ``get_state_dict`` and ``set_state_dict``.

Note that if there are multiple optimizers, all of the optimizers will be patched.
So users only need to call one of the state_dict() to get the full result.

Examples:
    from torch.distributed.fsdp import FullyShardedDataParallel as FSDP
    from torch.distributed.checkpoint.state_dict import patch_model_state_dict

    model = fsdp(model)
    patch_model_state_dict(model)

Args:
    model (nn.Module): the nn.Module to the model.
    options (StateDictOptions): the options to control how
        model state_dict and optimizer state_dict should be loaded. See
        `StateDictOptions` for the details.

Returns:
    None
