class_docstr: This corresponds to the 'PoolFormerBlock' class in the original implementation.
class_docstr_tok: ["This","corresponds","to","the","'PoolFormerBlock","'","class","in","the","original","implementation","."]
code: def forward(self, hidden_states):
      if self.use_layer_scale:
          pooling_output = self.pooling(self.before_norm(hidden_states))
          scaled_op = (
              self.layer_scale_1.unsqueeze(-1).unsqueeze(-1)
              * pooling_output
          )
          # First residual connection
          hidden_states = hidden_states + self.drop_path(scaled_op)
          outputs = ()
  
          layer_output = self.output(self.after_norm(hidden_states))
          scaled_op = (
              self.layer_scale_2.unsqueeze(-1).unsqueeze(-1)
              * layer_output
          )
          # Second residual connection
          output = hidden_states + self.drop_path(scaled_op)
  
          outputs = (output,) + outputs
          return outputs
  
      else:
          pooling_output = self.drop_path(
              self.pooling(self.before_norm(hidden_states))
          )
          # First residual connection
          hidden_states = pooling_output + hidden_states
          outputs = ()
  
          # Second residual connection inside the PoolFormerOutput block
          layer_output = self.drop_path(
              self.output(self.after_norm(hidden_states))
          )
          output = hidden_states + layer_output
  
          outputs = (output,) + outputs
          return outputs
  
imports: import collections.abc
  from typing import Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifierOutputWithNoAttention
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from .configuration_poolformer import PoolFormerConfig
label_desc: Use image node_id 2 for calling the PoolFormerLayer obj's underlying member method code with example usage: obj.forward(hidden_states) and returns: outputs, outputs