code: def fetch_ecg(
      return_X_y: bool = False,
  ) -> Union[
      Bunch,
      Tuple[
          Tuple[np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray]
      ],
  ]:
      """
      Fetch ECG5000 data. The dataset contains 5000 ECG's, originally obtained from
      Physionet (https://archive.physionet.org/cgi-bin/atm/ATM) under the name
      "BIDMC Congestive Heart Failure Database(chfdb)", record "chf07".
  
      Parameters
      ----------
      return_X_y
          Bool, whether to only return the data and target values or a Bunch object.
  
      Returns
      -------
      Bunch
          Train and test datasets with labels.
      (train data, train target), (test data, test target)
          Tuple of tuples if 'return_X_y' equals True.
      """
      Xy_train = load_url_arff(
          "https://storage.googleapis.com/seldon-datasets/ecg/ECG5000_TRAIN.arff"
      )
      X_train, y_train = Xy_train[:, :-1], Xy_train[:, -1]
      Xy_test = load_url_arff(
          "https://storage.googleapis.com/seldon-datasets/ecg/ECG5000_TEST.arff"
      )
      X_test, y_test = Xy_test[:, :-1], Xy_test[:, -1]
      if return_X_y:
          return (X_train, y_train), (X_test, y_test)
      else:
          return Bunch(
              data_train=X_train,
              data_test=X_test,
              target_train=y_train,
              target_test=y_test,
          )
  
imports: import io
  import logging
  from io import BytesIO
  from typing import List, Tuple, Type, Union
  from xml.etree import ElementTree
  import dill
  import numpy
  import pandas
  import requests
  from alibi_detect.utils.data import Bunch
  from alibi_detect.utils.url import _join_url
  from requests import RequestException
  from urllib.error import URLError
  from scipy.io import arff
  from sklearn.datasets import fetch_kddcup99
label_desc: Use image node_id 3 for calling a global function with example usage: fetch_ecg(return_X_y) and returns: X_train,  y_train,  X_test,  y_test, Bunch