class_docstr: Computes the softmax of a 2d, 3d, or 4d input tensor.
  
  Arguments
  ---------
  apply_log : bool
      Whether to apply the log function before softmax.
  dim : int
      If the dimension where softmax is applied.
  reshape: bool
      whether to apply reshaping (true by default)
  dtype: torch.dtype
      dtype of the output tensor
  
  Example
  -------
  >>> classifier = Softmax()
  >>> inputs = torch.rand(10, 50, 40)
  >>> output = classifier(inputs)
  >>> output.shape
  torch.Size([10, 50, 40])
class_docstr_tok: ["Computes","the","softmax","of","a","2d",",","3d",",","or","4d","input","tensor",".","Arguments","--","--","--","--","-","apply_log",":","bool","Whether","to","apply","the","log","function","before","softmax",".","dim",":","int","If","the","dimension","where","softmax","is","applied",".","reshape",":","bool","whether","to","apply","reshaping","(","true","by","default",")","dtype",":","torch.dtype","dtype","of","the","output","tensor","Example","--","--","--","-",">",">",">","classifier","=","Softmax","(",")",">",">",">","inputs","=","torch.rand","(","10",",","50",",","40",")",">",">",">","output","=","classifier","(","inputs",")",">",">",">","output.shape","torch.Size","(","[","10",",","50",",","40","]",")"]
docstr: Returns the softmax of the input tensor.
  
  Arguments
  ---------
  x : torch.Tensor
      Input tensor.
docstr_tok: ["Returns","the","softmax","of","the","input","tensor",".","Arguments","--","--","--","--","-","x",":","torch.Tensor","Input","tensor","."]
code: def forward(self, x):
      """Returns the softmax of the input tensor.
  
      Arguments
      ---------
      x : torch.Tensor
          Input tensor.
      """
      # Reshaping the tensors
      dims = x.shape
  
      if self.reshape:
          if len(dims) == 3:
              x = x.reshape(dims[0] * dims[1], dims[2])
  
          if len(dims) == 4:
              x = x.reshape(dims[0] * dims[1], dims[2], dims[3])
  
      x_act = self.act(x, dim=self.dim, dtype=self.dtype)
  
      # Retrieving the original shape format
      if self.reshape:
          if len(dims) == 3:
              x_act = x_act.reshape(dims[0], dims[1], dims[2])
  
          if len(dims) == 4:
              x_act = x_act.reshape(dims[0], dims[1], dims[2], dims[3])
  
      return x_act
  
file_path: speechbrain/speechbrain/nnet/activations.py
imports: import torch
  import logging
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the Softmax obj's underlying member method code with example usage: obj.forward(x) and returns: x_act