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","``",")"]
docstr: Forward pass for encoding layer.
  
  Size depends on whether frequency or time
  
  Args:
      x (torch.Tensor): tensor input of shape `(B, C, F, T)` for frequency and shape
          `(B, C, T)` for time
      inject (torch.Tensor, optional): on last layer, combine frequency and time branches through inject param,
          same shape as x (default: ``None``)
  
  Returns:
      Tensor
          output tensor after encoder layer of shape `(B, C, F / stride, T)` for frequency
              and shape `(B, C, ceil(T / stride))` for time
docstr_tok: ["Forward","pass","for","encoding","layer",".","Size","depends","on","whether","frequency","or","time","Args",":","x","(","torch.Tensor",")",":","tensor","input","of","shape","`","(","B",",","C",",","F",",","T",")","`","for","frequency","and","shape","`","(","B",",","C",",","T",")","`","for","time","inject","(","torch.Tensor",",","optional",")",":","on","last","layer",",","combine","frequency","and","time","branches","through","inject","param",",","same","shape","as","x","(","default",":","``","None","``",")","Returns",":","Tensor","output","tensor","after","encoder","layer","of","shape","`","(","B",",","C",",","F","\/","stride",",","T",")","`","for","frequency","and","shape","`","(","B",",","C",",","ceil","(","T","\/","stride",")",")","`","for","time"]
code: def forward(
      self, x: torch.Tensor, inject: Optional[torch.Tensor] = None
  ) -> torch.Tensor:
      r"""Forward pass for encoding layer.
  
      Size depends on whether frequency or time
  
      Args:
          x (torch.Tensor): tensor input of shape `(B, C, F, T)` for frequency and shape
              `(B, C, T)` for time
          inject (torch.Tensor, optional): on last layer, combine frequency and time branches through inject param,
              same shape as x (default: ``None``)
  
      Returns:
          Tensor
              output tensor after encoder layer of shape `(B, C, F / stride, T)` for frequency
                  and shape `(B, C, ceil(T / stride))` for time
      """
  
      if not self.freq and x.dim() == 4:
          B, C, Fr, T = x.shape
          x = x.view(B, -1, T)
  
      if not self.freq:
          le = x.shape[-1]
          if not le % self.stride == 0:
              x = F.pad(x, (0, self.stride - (le % self.stride)))
      y = self.conv(x)
      if self.empty:
          return y
      if inject is not None:
          if inject.shape[-1] != y.shape[-1]:
              raise ValueError("Injection shapes do not align")
          if inject.dim() == 3 and y.dim() == 4:
              inject = inject[:, :, None]
          y = y + inject
      y = F.gelu(self.norm1(y))
      if self.freq:
          B, C, Fr, T = y.shape
          y = y.permute(0, 2, 1, 3).reshape(-1, C, T)
          y = self.dconv(y)
          y = y.view(B, Fr, C, T).permute(0, 2, 1, 3)
      else:
          y = self.dconv(y)
      z = self.norm2(self.rewrite(y))
      z = F.glu(z, dim=1)
      return z
  
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 2 for calling the _HEncLayer obj's underlying member method code with example usage: obj.forward(x, inject) and returns: z, y