class_docstr: Encoder layer. This used both by the time and the frequency branch.
  Args:
      chin (int): number of input channels.
      chout (int): number of output channels.
      kernel_size (int, optional): Kernel size for encoder (Default: 8)
      stride (int, optional): Stride for encoder layer (Default: 4)
      norm_groups (int, optional): number of groups for group norm. (Default: 4)
      empty (bool, optional): used to make a layer with just the first conv. this is used
          before merging the time and freq. branches. (Default: ``False``)
      freq (bool, optional): boolean for whether conv layer is for frequency domain (Default: ``True``)
      norm_type (string, optional): Norm type, either ``group_norm `` or ``none`` (Default: ``group_norm``)
      context (int, optional): context size for the 1x1 conv. (Default: 0)
      dconv_kw (Dict[str, Any] or None, optional): dictionary of kwargs for the DConv class. (Default: ``None``)
      pad (bool, optional): true to pad the input. Padding is done so that the output size is
          always the input size / stride. (Default: ``True``)
class_docstr_tok: ["Encoder","layer",".","This","used","both","by","the","time","and","the","frequency","branch",".","Args",":","chin","(","int",")",":","number","of","input","channels",".","chout","(","int",")",":","number","of","output","channels",".","kernel_size","(","int",",","optional",")",":","Kernel","size","for","encoder","(","Default",":","8",")","stride","(","int",",","optional",")",":","Stride","for","encoder","layer","(","Default",":","4",")","norm_groups","(","int",",","optional",")",":","number","of","groups","for","group","norm",".","(","Default",":","4",")","empty","(","bool",",","optional",")",":","used","to","make","a","layer","with","just","the","first","conv",".","this","is","used","before","merging","the","time","and","freq",".","branches",".","(","Default",":","``","False","``",")","freq","(","bool",",","optional",")",":","boolean","for","whether","conv","layer","is","for","frequency","domain","(","Default",":","``","True","``",")","norm_type","(","string",",","optional",")",":","Norm","type",",","either","``","group_norm","``","or","``","none","``","(","Default",":","``","group_norm","``",")","context","(","int",",","optional",")",":","context","size","for","the","1x1","conv",".","(","Default",":","0",")","dconv_kw","(","Dict","[","str",",","Any","]","or","None",",","optional",")",":","dictionary","of","kwargs","for","the","DConv","class",".","(","Default",":","``","None","``",")","pad","(","bool",",","optional",")",":","true","to","pad","the","input",".","Padding","is","done","so","that","the","output","size","is","always","the","input","size","\/","stride",".","(","Default",":","``","True","``",")"]
code: def __init__(
      self,
      chin: int,
      chout: int,
      kernel_size: int = 8,
      stride: int = 4,
      norm_groups: int = 4,
      empty: bool = False,
      freq: bool = True,
      norm_type: str = "group_norm",
      context: int = 0,
      dconv_kw: Optional[Dict[str, Any]] = None,
      pad: bool = True,
  ):
      super().__init__()
      if dconv_kw is None:
          dconv_kw = {}
      norm_fn = lambda d: nn.Identity()  # noqa
      if norm_type == "group_norm":
          norm_fn = lambda d: nn.GroupNorm(norm_groups, d)  # noqa
      pad_val = kernel_size // 4 if pad else 0
      klass = nn.Conv1d
      self.freq = freq
      self.kernel_size = kernel_size
      self.stride = stride
      self.empty = empty
      self.pad = pad_val
      if freq:
          kernel_size = [kernel_size, 1]
          stride = [stride, 1]
          pad_val = [pad_val, 0]
          klass = nn.Conv2d
      self.conv = klass(chin, chout, kernel_size, stride, pad_val)
      self.norm1 = norm_fn(chout)
  
      if self.empty:
          self.rewrite = nn.Identity()
          self.norm2 = nn.Identity()
          self.dconv = nn.Identity()
      else:
          self.rewrite = klass(
              chout, 2 * chout, 1 + 2 * context, 1, context
          )
          self.norm2 = norm_fn(2 * chout)
          self.dconv = _DConv(chout, **dconv_kw)
  
imports: import math
  import typing
  from typing import Any, Dict, List, Optional
  import torch
  from torch import nn
  from torch.nn import functional
label_desc: Use image node_id 1 to create a new _HEncLayer object from inherited base classes: torch.nn with example: obj = _HEncLayer(chin, chout, kernel_size, stride, norm_groups, empty, freq, norm_type, context, dconv_kw, pad)