code: def build_loss_side_effect(return_value=RETURN_VALUE):
      def loss_side_effect(item):
          loss_object_mock = MagicMock(return_value=return_value)
          loss_class_mock = MagicMock(return_value=loss_object_mock)
          valid_losses = ["cross_entropy", "multi"]
          if isinstance(item, collections.abc.MutableMapping):
              if item["type"] not in valid_losses:
                  return None
          elif item not in valid_losses:
              return None
          else:
              return loss_class_mock
  
      return loss_side_effect
  
imports: import collections
  import unittest
  from unittest.mock import MagicMock
  import mmf.modules.losses
  import torch
  import torch.nn
  import torch.nn.functional
  from mmf.common.registry import registry
  from mmf.common.sample import SampleList
label_desc: Use image node_id 1 for calling a global function with example usage: build_loss_side_effect(return_value) and returns: loss_side_effect, None, None, loss_class_mock