code: def test_fetch_metadata_function_with_indices(tmpdir):
      sample_run_ = sample_run()
      # Setup and run three experiments
      root = tmpdir.strpath
      tinydb_obs = run_test_experiment(
          exp_name="experiment 1 alpha", exp_id="1234", root_dir=root
      )
      tinydb_obs = run_test_experiment(
          exp_name="experiment 2 beta", exp_id="5678", root_dir=root
      )
      tinydb_obs = run_test_experiment(
          exp_name="experiment 3 alpha", exp_id="9990", root_dir=root
      )
  
      tinydb_reader = TinyDbReader(root)
  
      # Test fetch by indices
      res = tinydb_reader.fetch_metadata(indices=-1)
      res2 = tinydb_reader.fetch_metadata(indices=[-1])
      assert strip_file_handles(res) == strip_file_handles(res2)
      res3 = tinydb_reader.fetch_metadata(indices=[0, -1])
      assert len(res3) == 2
  
      exp1_res = tinydb_reader.fetch_metadata(indices=0)
      assert len(exp1_res) == 1
      assert exp1_res[0]["experiment"]["name"] == "experiment 1 alpha"
      assert exp1_res[0]["_id"] == "1234"
  
      # Test Exception
      with pytest.raises(ValueError):
          tinydb_reader.fetch_metadata(indices=4)
  
      # Test returned values
      exp1 = strip_file_handles(exp1_res)[0]
  
      sample_run_["ex_info"]["name"] = "experiment 1 alpha"
      sample_run_["ex_info"]["sources"] = [
          ["setup.py", get_digest("setup.py")]
      ]
  
      assert exp1 == {
          "_id": "1234",
          "experiment": sample_run_["ex_info"],
          "format": tinydb_obs.VERSION,
          "command": sample_run_["command"],
          "host": sample_run_["host_info"],
          "start_time": sample_run_["start_time"],
          "heartbeat": datetime.datetime(1999, 5, 5, 5, 5, 5, 5),
          "info": {"my_info": [1, 2, 3], "nr": 7},
          "captured_out": "some output",
          "artifacts": [
              [
                  "about",
                  "sacred/__about__.py",
                  get_digest("sacred/__about__.py"),
              ]
          ],
          "config": sample_run_["config"],
          "meta": sample_run_["meta_info"],
          "status": "COMPLETED",
          "resources": [
              ["sacred/__init__.py", get_digest("sacred/__init__.py")]
          ],
          "result": 42,
          "stop_time": datetime.datetime(1999, 5, 5, 6, 6, 6, 6),
      }
  
imports: from __future__ import division, print_function, unicode_literals, absolute_import
  import datetime
  import os
  import tempfile
  import io
  import pytest
  from tinydb import Query
  from sacred.dependencies import get_digest
  from sacred.observers.tinydb_hashfs import TinyDbObserver, TinyDbReader
label_desc: Use image node_id 6 for calling a global function with example usage: test_fetch_metadata_function_with_indices(tmpdir) without return types