class_docstr: Custom Gated Linear Unit activation.
  Applies a modified gated linear unit :math:`a * f(b)` where :math:`a` is the first half
  of the input matrices, :math:`b` is the second half, and :math:`f` is a provided activation
  function (i.e. sigmoid, swish, etc.).
  
  Args:
      activation (nn.Module): The custom activation to apply in the Gated Linear Unit
      dim (int): the dimension on which to split the input. Default: -1
  
  Shape:
      - Input: :math:`(st_1, N, st_2)` where `*` means, any number of additional
        dimensions
      - Output: :math:`(st_1, M, st_2)` where :math:`M=N/2`
  
  Examples::
      >>> m = CustomGLU(nn.Sigmoid())
      >>> input = torch.randn(4, 2)
      >>> output = m(input)
class_docstr_tok: ["Custom","Gated","Linear","Unit","activation",".","Applies","a","modified","gated","linear","unit",":","math",":","`","a","*","f","(","b",")","`","where",":","math",":","`","a","`","is","the","first","half","of","the","input","matrices",",",":","math",":","`","b","`","is","the","second","half",",","and",":","math",":","`","f","`","is","a","provided","activation","function","(","i.e",".","sigmoid",",","swish",",","etc.",")",".","Args",":","activation","(","nn.Module",")",":","The","custom","activation","to","apply","in","the","Gated","Linear","Unit","dim","(","int",")",":","the","dimension","on","which","to","split","the","input",".","Default",":","-1","Shape",":","-","Input",":",":","math",":","`","(","\u0007st_1",",","N",",","\u0007st_2",")","`","where","`","*","`","means",",","any","number","of","additional","dimensions","-","Output",":",":","math",":","`","(","\u0007st_1",",","M",",","\u0007st_2",")","`","where",":","math",":","`","M=N\/2","`","Examples",":",":",">",">",">","m","=","CustomGLU","(","nn.Sigmoid","(",")",")",">",">",">","input","=","torch.randn","(","4",",","2",")",">",">",">","output","=","m","(","input",")"]
code: def forward(self, x: Tensor):
      assert x.shape[self.dim] % 2 == 0  # M = N / 2
      a, b = torch.chunk(x, 2, dim=self.dim)
      return a * self.activation(b)
  
file_path: audiocraft/audiocraft/modules/activations.py
imports: import torch
  import torch.nn
  from torch import Tensor
  from typing import Union, Callable
label_desc: Use image node_id 2 for calling the CustomGLU obj's underlying member method code with example usage: obj.forward(x) and returns: unknown