code: def default_train_fn(
      model: nn.Module, x: torch.Tensor, *args, **kwargs
  ) -> None:
      """
      Example of a default train_fn to be passed to ``compare_gradients``.
  
      Args:
          Recommend to always have *args and **kwargs so you can pass whatever you want to it,
          plus anything else that you need (in this case, we directly refer to x so we add it to
          the list)
  
      Returns:
          Nothing. But it must call ``loss.backward()`` to fill in the gradients.
      """
      model.train()
      criterion = nn.MSELoss()
      logits = model(x)
      y = torch.zeros_like(logits)
      loss = criterion(logits, y)
      loss.backward()
  
file_path: opacus/opacus/tests/dp_layers/common.py
imports: import io
  import unittest
  from typing import Callable, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.utils.rnn import PackedSequence, pad_packed_sequence
  from torch.testing import assert_close
label_desc: Use image node_id 3 for calling a global function with example usage: default_train_fn(model, x) without return types