code: def reweight_loss_dict(losses: dict, weight: float) -> dict:
      """Reweight losses in the dict by weight.
  
      Args:
          losses (dict):  A dictionary of loss components.
          weight (float): Weight for loss components.
  
      Returns:
              dict: A dictionary of weighted loss components.
      """
      for name, loss in losses.items():
          if "loss" in name:
              if isinstance(loss, Sequence):
                  losses[name] = [item * weight for item in loss]
              else:
                  losses[name] = loss * weight
      return losses
  
imports: from functools import partial
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from mmengine.utils import digit_version
  from six.moves import map, zip
  from torch import Tensor
  from torch.autograd import Function
  from torch.nn import functional
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import BaseBoxes, get_box_type, stack_boxes
  from mmdet.structures.mask import BitmapMasks, PolygonMasks
  from mmdet.utils import OptInstanceList
label_desc: Use image node_id 20 for calling a global function with example usage: reweight_loss_dict(losses, weight) and returns: losses