class_docstr: A subclass of [`AllenNlpTestCase`](./test_case.md)
  with added methods for testing [`Model`](../../models/model.md) subclasses.
class_docstr_tok: ["A","subclass","of","[","`","AllenNlpTestCase","`","]","(",".\/test_case.md",")","with","added","methods","for","testing","[","`","Model","`","]","(","..","\/","..","\/models\/model.md",")","subclasses","."]
code: def assert_fields_equal(
      self, field1, field2, name: str, tolerance: float = 1e-6
  ) -> None:
      if isinstance(field1, torch.Tensor):
          assert_allclose(
              field1.detach().cpu().numpy(),
              field2.detach().cpu().numpy(),
              rtol=tolerance,
              err_msg=name,
          )
      elif isinstance(field1, dict):
          assert field1.keys() == field2.keys()
          for key in field1:
              self.assert_fields_equal(
                  field1[key],
                  field2[key],
                  tolerance=tolerance,
                  name=name + "." + str(key),
              )
      elif isinstance(field1, (list, tuple)):
          assert len(field1) == len(field2)
          for i, (subfield1, subfield2) in enumerate(
              zip(field1, field2)
          ):
              self.assert_fields_equal(
                  subfield1,
                  subfield2,
                  tolerance=tolerance,
                  name=name + f"[{i}]",
              )
      elif isinstance(field1, (float, int)):
          assert_allclose(
              [field1], [field2], rtol=tolerance, err_msg=name
          )
      else:
          if field1 != field2:
              for key in field1.__dict__:
                  print(
                      key, getattr(field1, key) == getattr(field2, key)
                  )
          assert (
              field1 == field2
          ), f"{name}, {type(field1)}, {type(field2)}"
  
imports: import copy
  import json
  from os import PathLike
  import random
  from typing import Any, Dict, Iterable, Set, Union
  import torch
  import numpy
  from numpy.testing import assert_allclose
  from allennlp.commands.train import train_model_from_file
  from allennlp.common import Params
  from allennlp.common.testing.test_case import AllenNlpTestCase
  from allennlp.data import DatasetReader, Vocabulary
  from allennlp.data import DataLoader
  from allennlp.data.batch import Batch
  from allennlp.models import load_archive, Model
  from allennlp.training import GradientDescentTrainer
  from allennlp.confidence_checks.normalization_bias_verification import NormalizationBiasVerification
label_desc: Use image node_id 5 for calling the ModelTestCase obj's underlying member method code with example usage: obj.assert_fields_equal(field1, field2, name, tolerance) without return types