class_docstr: Returns cosine similarity between :math:`x_1` and :math:`x_2`, computed along `dim`.
  
  .. math ::
      \text{similarity} = \dfrac{x_1 \cdot x_2}{\max(\Vert x_1 \Vert _2 \cdot \Vert x_2 \Vert _2, \epsilon)}.
  
  Args:
      dim (int, optional): Dimension where cosine similarity is computed. Default: 1
      eps (float, optional): Small value to avoid division by zero.
          Default: 1e-8
  Shape:
      - Input1: :math:`(\ast_1, D, \ast_2)` where D is at position `dim`
      - Input2: :math:`(\ast_1, D, \ast_2)`, same number of dimensions as x1, matching x1 size at dimension `dim`,
            and broadcastable with x1 at other dimensions.
      - Output: :math:`(\ast_1, \ast_2)`
  Examples::
      >>> input1 = torch.randn(100, 128)
      >>> input2 = torch.randn(100, 128)
      >>> cos = nn.CosineSimilarity(dim=1, eps=1e-6)
      >>> output = cos(input1, input2)
class_docstr_tok: ["Returns","cosine","similarity","between",":","math",":","`","x_1","`","and",":","math",":","`","x_2","`",",","computed","along","`","dim","`",".","..","math",":",":","\\text","{","similarity","}","=","\\dfrac","{","x_1","\\cdot","x_2","}","{","\\max","(","\\Vert","x_1","\\Vert","_2","\\cdot","\\Vert","x_2","\\Vert","_2",",","\\epsilon",")","}",".","Args",":","dim","(","int",",","optional",")",":","Dimension","where","cosine","similarity","is","computed",".","Default",":","1","eps","(","float",",","optional",")",":","Small","value","to","avoid","division","by","zero",".","Default",":","1e-8","Shape",":","-","Input1",":",":","math",":","`","(","\\ast_1",",","D",",","\\ast_2",")","`","where","D","is","at","position","`","dim","`","-","Input2",":",":","math",":","`","(","\\ast_1",",","D",",","\\ast_2",")","`",",","same","number","of","dimensions","as","x1",",","matching","x1","size","at","dimension","`","dim","`",",","and","broadcastable","with","x1","at","other","dimensions",".","-","Output",":",":","math",":","`","(","\\ast_1",",","\\ast_2",")","`","Examples",":",":",">",">",">","input1","=","torch.randn","(","100",",","128",")",">",">",">","input2","=","torch.randn","(","100",",","128",")",">",">",">","cos","=","nn.CosineSimilarity","(","dim=1",",","eps=1e-6",")",">",">",">","output","=","cos","(","input1",",","input2",")"]
code: def forward(self, x1: Tensor, x2: Tensor) -> Tensor:
      return F.cosine_similarity(x1, x2, self.dim, self.eps)
  
file_path: pytorch/torch/nn/modules/distance.py
imports: from .module import Module
  from ..None import functional
  from torch import Tensor
label_desc: Use image node_id 2 for calling the CosineSimilarity obj's underlying member method code with example usage: obj.forward(x1, x2) and returns: F