code: def l2_loss(x1, x2, weights=None):
      if weights is None:
          return torch.mean((x1 - x2) ** 2) / 2.0
      else:
          return (
              torch.sum(
                  (weights / weights.norm(p=1)) * ((x1 - x2) ** 2)
              )
              / 2.0
          )
  
file_path: captum/captum/_utils/models/linear_model/train.py
imports: import time
  import warnings
  from typing import Any, Callable, Dict, List, Optional
  import torch
  import torch.nn
  from captum._utils.models.linear_model.model import LinearModel
  from torch.utils.data import DataLoader
label_desc: Use image node_id 1 for calling a global function with example usage: l2_loss(x1, x2, weights) and returns: unknown, unknown