(state, shard_size=None)
?
?
?
def filter_shard_state(state, shard_size=None):
    """ ? """
    for k, v in state.items():
        if shard_size is None:
            yield k, v

        if v is not None:
            v_split = []
            if isinstance(v, torch.Tensor):
                for v_chunk in torch.split(v, shard_size):
                    v_chunk = v_chunk.data.clone()
                    v_chunk.requires_grad = v.requires_grad
                    v_split.append(v_chunk)
            yield k, (v, v_split)
def filter_shard_state ( state , shard_size = None ) : for k , v in state . items ( ) : if shard_size is None : yield k , v if v is not None : v_split = [ ] if isinstance ( v , torch . Tensor ) : for v_chunk in torch . split ( v , shard_size ) : v_chunk = v_chunk . data . clone ( ) v_chunk . requires_grad = v . requires_grad v_split . append ( v_chunk ) yield k , ( v , v_split )