text: Title: How to compute loss using eval mode in val. py file for YOLOv5
  Body: ### Search before asking
  
  - [X] I have searched the YOLOv5 [issues](https://github.com/ultralytics/yolov5/issues) and [discussions](https://github.com/ultralytics/yolov5/discussions) and found no similar questions.
  
  
  ### Question
  
  Due to research requirements, I need to calculate the loss function value for each input image in the `eval mode` of the YOLO V5 model
  I modified the `run` function in the `val. py` file
  The `compute_loss` variable was specified as `ComputeLoss (model)` in it
  ```python
      # Configure
      model.eval()
      compute_loss = ComputeLoss(model)
      cuda = device.type != "cpu"
      is_coco = isinstance(data.get("val"), str) and data["val"].endswith(f"coco{os.sep}val2017.txt")  # COCO dataset
      nc = 1 if single_cls else int(data["nc"])  # number of classes
      iouv = torch.linspace(0.5, 0.95, 10, device=device)  # iou vector for mAP@0.5:0.95
      niou = iouv.numel()
  ```
  The following error will occur：
  ```python
  Traceback (most recent call last):
    File "val.py", line 626, in <module>
      main(opt)
    File "val.py", line 597, in main
      run(**vars(opt))
    File "xxxxxxxxx/.local/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
      return func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
    File "val.py", line 299, in run
      compute_loss = ComputeLoss(model)
                     ^^^^^^^^^^^^^^^^^^
    File "utils/loss.py", line 115, in __init__
      h = model.hyp  # hyperparameters
          ^^^^^^^^^
    File "xxxxxxxxxx/.local/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1931, in __getattr__
      raise AttributeError(
  AttributeError: 'DetectMultiBackend' object has no attribute 'hyp'
  ```
  When I imitate the training mode and adding the 'hyp' attribute to the YOLOv5 model using 'data/hyps/hyp.satch-low-yaml' will result in the following error：
  ```python
  Traceback (most recent call last):
    File "val.py", line 626, in <module>
      main(opt)
    File "val.py", line 597, in main
      run(**vars(opt))
    File "xxxxxxx/.local/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
      return func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
    File "val.py", line 299, in run
      compute_loss = ComputeLoss(model)
                     ^^^^^^^^^^^^^^^^^^
    File "utils/loss.py", line 129, in __init__
      m = de_parallel(model).model[-1]  # Detect() module
          ~~~~~~~~~~~~~~~~~~~~~~~~^^^^
  TypeError: 'DetectionModel' object is not subscriptable
  ```
  I really need the loss value.I look forward to your reply. I would be extremely grateful
  If it's not possible to directly modify `val. py` to achieve the goal, use 
  ```python
  torch.hub.load("yolo.pt")
  ```
   or 
  ```python
  from ultralytics import YOLO
  Model=YOLO ("yolo5. pt")
  ```
   and other methods can achieve the goal， I also look forward to your reply. I would greatly appreciate it
  
  ### Additional
  
  _No response_