class_docstr: An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
  models.
class_docstr_tok: ["An","abstract","class","to","handle","weights","initialization","and","a","simple","interface","for","downloading","and","loading","pretrained","models","."]
docstr: Initialize the weights
docstr_tok: ["Initialize","the","weights"]
code: def _init_weights(
      self, module: Union[nn.Linear, nn.Conv2d, nn.LayerNorm]
  ) -> None:
      """Initialize the weights"""
      if isinstance(module, (nn.Conv2d, nn.Linear)):
          nn.init.trunc_normal_(module.weight, std=0.02)
          if module.bias is not None:
              nn.init.constant_(module.bias, 0)
      elif isinstance(module, (nn.LayerNorm)):
          nn.init.constant_(module.bias, 0)
          nn.init.constant_(module.weight, 1.0)
  
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 ACT2CLS
  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_swiftformer import SwiftFormerConfig
label_desc: Use image node_id 1 for calling the SwiftFormerPreTrainedModel obj's underlying member method code with example usage: obj._init_weights(module) without return types