class_docstr: Simple mock of tf.slim Conv2d
class_docstr_tok: ["Simple","mock","of","tf.slim","Conv2d"]
docstr: Creates a standard Conv2d layer, similar to torch.nn.Conv2d
  
  Args:
      in_channels: Number of input channels
      out_channels: Number of output channels
      kernel: If int, the kernel is
          a tuple(x,x). Elsewise, the tuple can be specified
      stride: Controls the stride
          for the cross-correlation. If int, the stride is a
          tuple(x,x). Elsewise, the tuple can be specified
      padding: Controls the amount
          of implicit zero-paddings during the conv operation
      initializer: Initializer function for kernel weights
      activation_fn: Activation function at the end of layer
      bias_init: Initalize bias weights to bias_init const
docstr_tok: ["Creates","a","standard","Conv2d","layer",",","similar","to","torch.nn.Conv2d","Args",":","in_channels",":","Number","of","input","channels","out_channels",":","Number","of","output","channels","kernel",":","If","int",",","the","kernel","is","a","tuple","(","x",",","x",")",".","Elsewise",",","the","tuple","can","be","specified","stride",":","Controls","the","stride","for","the","cross-correlation",".","If","int",",","the","stride","is","a","tuple","(","x",",","x",")",".","Elsewise",",","the","tuple","can","be","specified","padding",":","Controls","the","amount","of","implicit","zero-paddings","during","the","conv","operation","initializer",":","Initializer","function","for","kernel","weights","activation_fn",":","Activation","function","at","the","end","of","layer","bias_init",":","Initalize","bias","weights","to","bias_init","const"]
code: def __init__(
      self,
      in_channels: int,
      out_channels: int,
      kernel: Union[int, Tuple[int, int]],
      stride: Union[int, Tuple[int, int]],
      padding: Union[int, Tuple[int, int]],
      # Defaulting these to nn.[..] will break soft torch import.
      initializer: Any = "default",
      activation_fn: Any = "default",
      bias_init: float = 0,
  ):
      """Creates a standard Conv2d layer, similar to torch.nn.Conv2d
  
      Args:
          in_channels: Number of input channels
          out_channels: Number of output channels
          kernel: If int, the kernel is
              a tuple(x,x). Elsewise, the tuple can be specified
          stride: Controls the stride
              for the cross-correlation. If int, the stride is a
              tuple(x,x). Elsewise, the tuple can be specified
          padding: Controls the amount
              of implicit zero-paddings during the conv operation
          initializer: Initializer function for kernel weights
          activation_fn: Activation function at the end of layer
          bias_init: Initalize bias weights to bias_init const
      """
      super(SlimConv2d, self).__init__()
      layers = []
      # Padding layer.
      if padding:
          layers.append(nn.ZeroPad2d(padding))
      # Actual Conv2D layer (including correct initialization logic).
      conv = nn.Conv2d(in_channels, out_channels, kernel, stride)
      if initializer:
          if initializer == "default":
              initializer = nn.init.xavier_uniform_
          initializer(conv.weight)
      nn.init.constant_(conv.bias, bias_init)
      layers.append(conv)
      # Activation function (if any; default=ReLu).
      if isinstance(activation_fn, str):
          if activation_fn == "default":
              activation_fn = nn.ReLU
          else:
              activation_fn = get_activation_fn(activation_fn, "torch")
      if activation_fn is not None:
          layers.append(activation_fn())
      # Put everything in sequence.
      self._model = nn.Sequential(*layers)
  
imports: import numpy
  from typing import Union, Tuple, Any, List
  from ray.rllib.models.utils import get_activation_fn
  from ray.rllib.utils.annotations import DeveloperAPI
  from ray.rllib.utils.framework import try_import_torch
  from ray.rllib.utils.typing import TensorType
label_desc: Use image node_id 1 to create a new SlimConv2d object from inherited base classes: nn with example: obj = SlimConv2d(in_channels, out_channels, kernel, stride, padding, initializer, activation_fn, bias_init)