code: def smooth_l1_loss(
      pred: Tensor, target: Tensor, beta: float = 1.0
  ) -> Tensor:
      """Smooth L1 loss.
  
      Args:
          pred (Tensor): The prediction.
          target (Tensor): The learning target of the prediction.
          beta (float, optional): The threshold in the piecewise function.
              Defaults to 1.0.
  
      Returns:
          Tensor: Calculated loss
      """
      assert beta > 0
      if target.numel() == 0:
          return pred.sum() * 0
  
      assert pred.size() == target.size()
      diff = torch.abs(pred - target)
      loss = torch.where(
          diff < beta, 0.5 * diff * diff / beta, diff - 0.5 * beta
      )
      return loss
  
file_path: mmdetection/mmdet/models/losses/smooth_l1_loss.py
imports: from typing import Optional
  import torch
  import torch.nn
  from torch import Tensor
  from mmdet.registry import MODELS
  from .utils import weighted_loss
label_desc: Use image node_id 1 for calling a global function with example usage: smooth_l1_loss(pred, target, beta) and returns: loss, unknown