class_docstr: Cfa Loss.
  
  Args:
      num_nearest_neighbors (int): Number of nearest neighbors.
      num_hard_negative_features (int): Number of hard negative features.
      radius (float): Radius of the hypersphere to search the soft boundary.
class_docstr_tok: ["Cfa","Loss",".","Args",":","num_nearest_neighbors","(","int",")",":","Number","of","nearest","neighbors",".","num_hard_negative_features","(","int",")",":","Number","of","hard","negative","features",".","radius","(","float",")",":","Radius","of","the","hypersphere","to","search","the","soft","boundary","."]
docstr: Compute the CFA loss.
  
  Args:
      distance (Tensor): Distance computed using target oriented features.
  
  Returns:
      Tensor: CFA loss.
docstr_tok: ["Compute","the","CFA","loss",".","Args",":","distance","(","Tensor",")",":","Distance","computed","using","target","oriented","features",".","Returns",":","Tensor",":","CFA","loss","."]
code: def forward(self, distance: Tensor) -> Tensor:
      """Compute the CFA loss.
  
      Args:
          distance (Tensor): Distance computed using target oriented features.
  
      Returns:
          Tensor: CFA loss.
      """
      num_neighbors = (
          self.num_nearest_neighbors + self.num_hard_negative_features
      )
      distance = distance.topk(num_neighbors, largest=False).values
  
      score = distance[:, :, : self.num_nearest_neighbors] - (
          self.radius**2
      ).to(distance.device)
      l_att = torch.mean(torch.max(torch.zeros_like(score), score))
  
      score = (self.radius**2).to(distance.device) - distance[
          :, :, self.num_hard_negative_features :
      ]
      l_rep = torch.mean(
          torch.max(torch.zeros_like(score), score - 0.1)
      )
  
      loss = (l_att + l_rep) * 1000
  
      return loss
  
imports: import torch
  from torch import Tensor, nn
label_desc: Use image node_id 2 for calling the CfaLoss obj's underlying member method code with example usage: obj.forward(distance) and returns: loss