code: def test_create_index_existing_name(idx):
      # GH11193, when an existing index is passed, and a new name is not
      # specified, the new index should inherit the previous object name
      index = idx
      index.names = ["foo", "bar"]
      result = Index(index)
      expected = Index(
          Index(
              [
                  ("foo", "one"),
                  ("foo", "two"),
                  ("bar", "one"),
                  ("baz", "two"),
                  ("qux", "one"),
                  ("qux", "two"),
              ],
              dtype="object",
          )
      )
      tm.assert_index_equal(result, expected)
  
      result = Index(index, name="A")
      expected = Index(
          Index(
              [
                  ("foo", "one"),
                  ("foo", "two"),
                  ("bar", "one"),
                  ("baz", "two"),
                  ("qux", "one"),
                  ("qux", "two"),
              ],
              dtype="object",
          ),
          name="A",
      )
      tm.assert_index_equal(result, expected)
  
imports: from datetime import date, datetime
  import itertools
  import numpy
  import pytest
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
  import pandas
  from pandas import Index, MultiIndex, Series, Timestamp, date_range
  import pandas._testing
label_desc: Use image node_id 36 for calling a global function with example usage: test_create_index_existing_name(idx) without return types