parameters: (self, *inputs, **kwargs)
return_statement: return fw
docstring: A wrapper for Sharding Stage2 layer.
          - Fresh trainable params or rebuild grad storage
          - Sync layer's buffer params
          - Clear all flags states
          - Forward for origin layers
docstring_summary: A wrapper for Sharding Stage2 layer.
          - Fresh trainable params or rebuild grad storage
          - Sync layer's buffer params
          - Clear all flags states
          - Forward for origin layers
docstring_tokens: A wrapper for Sharding Stage2 layer . - Fresh trainable params or rebuild grad storage - Sync layer s buffer params - Clear all flags states - Forward for origin layers
function: def forward(self, *inputs, **kwargs):
          """
          A wrapper for Sharding Stage2 layer.
          - Fresh trainable params or rebuild grad storage
          - Sync layer's buffer params
          - Clear all flags states
          - Forward for origin layers
          """
  
          # Whether to need to reset trainable parameters
          needs_fresh = len(self._bw_hooks) == 0 and self.training
  
          if self._auto_refresh_trainable:
              needs_fresh |= self._detect_train_change()
  
          # Front hook
          self._init_internal_storage(needs_fresh)
  
          # Sync layer's buffers state
          if self._sync_buffers:
              self.__sync_buffers()
  
          # Normal FW on the base model
          fw = self._layer(*inputs, **kwargs)
  
          return fw
function_tokens: def forward ( self , * inputs , * * kwargs ) : # Whether to need to reset trainable parameters needs_fresh = len ( self . _bw_hooks ) == 0 and self . training if self . _auto_refresh_trainable : needs_fresh |= self . _detect_train_change ( ) # Front hook self . _init_internal_storage ( needs_fresh ) # Sync layer's buffers state if self . _sync_buffers : self . __sync_buffers ( ) # Normal FW on the base model fw = self . _layer ( * inputs , * * kwargs ) return fw