code: def optimize_compare(self, subscripts, operands=None):
      # Tests all paths of the optimization function against
      # conventional einsum
      if operands is None:
          args = [subscripts]
          terms = subscripts.split("->")[0].split(",")
          for term in terms:
              dims = [global_size_dict[x] for x in term]
              args.append(np.random.rand(*dims))
      else:
          args = [subscripts] + operands
  
      noopt = np.einsum(*args, optimize=False)
      opt = np.einsum(*args, optimize="greedy")
      assert_almost_equal(opt, noopt)
      opt = np.einsum(*args, optimize="optimal")
      assert_almost_equal(opt, noopt)
  
imports: import functools
  import itertools
  from unittest import expectedFailure, skipIf, SkipTest
  import torch._numpy
  from pytest import raises
  from torch._numpy.testing import assert_, assert_allclose, assert_almost_equal, assert_array_equal, assert_equal, suppress_warnings
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, run_tests, TestCase
label_desc: Use image node_id 24 for calling the TestEinsum obj's underlying member method code with example usage: obj.optimize_compare(subscripts, operands) without return types