code: def sanity_check_tensor(
      tensor_name: str,
      old_tensor: torch.Tensor,
      new_tensor: torch.Tensor,
  ) -> None:
      if old_tensor.type() != new_tensor.type():
          raise ValueError(
              f"Type mismatch for tensor {tensor_name}. Old tensor had type of "
              f"{old_tensor.type()} while new tensor has type of {new_tensor.type()}."
          )
      if old_tensor.size() != new_tensor.size():
          raise ValueError(
              f"Size mismatch for tensor {tensor_name} of type {old_tensor.type()}. "
              f"Old tensor had size of {old_tensor.size()} while new tensor "
              f"has size of {new_tensor.size()}."
          )
  
      if is_integer_tensor(old_tensor):
          # The following sanity check is only relevant for integer tensors - which
          # we expect to be index-like, and therefore should remain constant and not
          # be averaged over.
          if not torch.all(old_tensor == new_tensor):
              raise ValueError(
                  f"Integer tensor {tensor_name} of type {old_tensor.type()} "
                  f"and size {old_tensor.size()} had "
                  f"{torch.sum(old_tensor != new_tensor).item()} mismatched elements."
              )
  
imports: import os
  from collections import deque, OrderedDict
  from typing import Any, Deque, Dict, List, Optional, Tuple
  import torch
  from fairseq import checkpoint_utils, utils
  from pytorch_translate import constants
  from pytorch_translate.file_io import PathManager
label_desc: Use image node_id 6 for calling a global function with example usage: sanity_check_tensor(tensor_name, old_tensor, new_tensor) without return types