code: def test_unique_1d(self):
      def check_all(a, b, i1, i2, c, dt):
          base_msg = "check {0} failed for type {1}"
  
          msg = base_msg.format("values", dt)
          v = unique(a)
          assert_array_equal(v, b, msg)
  
          #      msg = base_msg.format('return_index', dt)
          #      v, j = unique(a, True, False, False)
          #      assert_array_equal(v, b, msg)
          #      assert_array_equal(j, i1, msg)
  
          msg = base_msg.format("return_inverse", dt)
          v, j = unique(a, False, True, False)
          assert_array_equal(v, b, msg)
          assert_array_equal(j, i2, msg)
  
          msg = base_msg.format("return_counts", dt)
          v, j = unique(a, False, False, True)
          assert_array_equal(v, b, msg)
          assert_array_equal(j, c, msg)
  
          #      msg = base_msg.format('return_index and return_inverse', dt)
          #      v, j1, j2 = unique(a, True, True, False)
          #      assert_array_equal(v, b, msg)
          #      assert_array_equal(j1, i1, msg)
          #      assert_array_equal(j2, i2, msg)
  
          #      msg = base_msg.format('return_index and return_counts', dt)
          #      v, j1, j2 = unique(a, True, False, True)
          #      assert_array_equal(v, b, msg)
          #      assert_array_equal(j1, i1, msg)
          #      assert_array_equal(j2, c, msg)
  
          msg = base_msg.format("return_inverse and return_counts", dt)
          v, j1, j2 = unique(a, False, True, True)
          assert_array_equal(v, b, msg)
          assert_array_equal(j1, i2, msg)
          assert_array_equal(j2, c, msg)
  
      #      msg = base_msg.format(('return_index, return_inverse '
      #                             'and return_counts'), dt)
      #      v, j1, j2, j3 = unique(a, True, True, True)
      #      assert_array_equal(v, b, msg)
      #      assert_array_equal(j1, i1, msg)
      #      assert_array_equal(j2, i2, msg)
      #      assert_array_equal(j3, c, msg)
  
      a = [5, 7, 1, 2, 1, 5, 7] * 10
      b = [1, 2, 5, 7]
      i1 = [2, 3, 0, 1]
      i2 = [2, 3, 0, 1, 0, 2, 3] * 10
      c = np.multiply([2, 1, 2, 2], 10)
  
      # test for numeric arrays
      types = []
      types.extend(np.typecodes["AllInteger"])
      types.extend(np.typecodes["AllFloat"])
      for dt in types:
          if dt in "FD":
              # RuntimeError: "unique" not implemented for 'ComplexFloat'
              continue
  
          aa = np.array(a, dt)
          bb = np.array(b, dt)
          check_all(aa, bb, i1, i2, c, dt)
  
      # test for ticket #2799
      # RuntimeError: "unique" not implemented for 'ComplexFloat'
      #  aa = [1. + 0.j, 1 - 1.j, 1]
      #  assert_array_equal(np.unique(aa), [1. - 1.j, 1. + 0.j])
  
      # test for ticket #4785
      a = [(1, 2), (1, 2), (2, 3)]
      unq = [1, 2, 3]
      inv = [0, 1, 0, 1, 1, 2]
      a1 = unique(a)
      assert_array_equal(a1, unq)
      a2, a2_inv = unique(a, return_inverse=True)
      assert_array_equal(a2, unq)
      assert_array_equal(a2_inv, inv)
  
      # test for ticket #9137
      a = []
      #    a1_idx = np.unique(a, return_index=True)[1]
      a2_inv = np.unique(a, return_inverse=True)[1]
      #    a3_idx, a3_inv = np.unique(a, return_index=True,
      #                               return_inverse=True)[1:]
      #    assert_equal(a1_idx.dtype, np.intp)
      assert_equal(a2_inv.dtype, np.intp)
  
imports: from unittest import skipIf
  import numpy
  from pytest import raises
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, run_tests, subtest, TEST_WITH_TORCHDYNAMO, TestCase, xpassIfTorchDynamo
label_desc: Use image node_id 1 for calling the TestUnique obj's underlying member method code with example usage: obj.test_unique_1d() without return types