def get_bower_package(self, url, dest=None, version=None,
                          process_deps=True):
        dest = dest or Path(".") / "assets"
        parsed_url = urlparse(url)
        if parsed_url.scheme == "git" or parsed_url.path.endswith(".git"):
            if parsed_url.netloc == "github.com":
                user, repo = parsed_url.path[1:-4].split("/")
                response = get(github_api_uri +
                               "/repos/{}/{}/tags".format(user, repo))
                tags = response.json()
                target = None
                if not len(tags):
                    click.secho("fatal: no tags exist for {}/{}".format(
                        user, repo), fg="red")
                    raise InvalidPackageError
                if version is None:
                    target = tags[0]
                else:
                    for tag in tags:
                        if semver.match(tag["name"],
                                        Bower.clean_semver(version)):
                            target = tag
                            break
                if not target:
                    click.secho(
                        "fatal: failed to find matching tag for "
                        "{user}/{repo} {version}".format(user, repo, version),
                        fg="red")
                    raise VersionNotFoundError
                click.secho("installing {}/{}#{}".format(
                    user, repo, tags[0]["name"]), fg="green")
                return self.get_bower_package(
                    url=target["zipball_url"],
                    dest=dest,
                    version=version)
            raise NotImplementedError
            click.echo("git clone {url}".format(url=url))
            cmd = envoy.run('git clone {url} "{dest}"'.format(
                url=url, dest=dest))
        elif parsed_url.scheme in ("http", "https"):
            zip_dest = download_file(url, dest=self.temp_dir,
                                     label="{dest_basename}",
                                     expected_extension="zip")
            with zipfile.ZipFile(zip_dest, "r") as pkg:
                return self.extract_bower_zipfile(pkg, dest,
                                                  expected_version=version)
                # pkg.extractall(str(dest))
        else:
            click.secho("protocol currently unsupported :(")
            sys.exit(1)
def __init__(self, model, data):
        # try and import pytorch
        global torch
        if torch is None:
            import torch
            if version.parse(torch.__version__) < version.parse("0.4"):
                warnings.warn("Your PyTorch version is older than 0.4 and not supported.")

        # check if we have multiple inputs
        self.multi_input = False
        if type(data) == list:
            self.multi_input = True
        if type(data) != list:
            data = [data]
        self.data = data
        self.layer = None
        self.input_handle = None
        self.interim = False
        self.interim_inputs_shape = None
        self.expected_value = None  # to keep the DeepExplainer base happy
        if type(model) == tuple:
            self.interim = True
            model, layer = model
            model = model.eval()
            self.layer = layer
            self.add_target_handle(self.layer)

            # if we are taking an interim layer, the 'data' is going to be the input
            # of the interim layer; we will capture this using a forward hook
            with torch.no_grad():
                _ = model(*data)
                interim_inputs = self.layer.target_input
                if type(interim_inputs) is tuple:
                    # this should always be true, but just to be safe
                    self.interim_inputs_shape = [i.shape for i in interim_inputs]
                else:
                    self.interim_inputs_shape = [interim_inputs.shape]
            self.target_handle.remove()
            del self.layer.target_input
        self.model = model.eval()

        self.multi_output = False
        self.num_outputs = 1
        with torch.no_grad():
            outputs = model(*data)

            # also get the device everything is running on
            self.device = outputs.device
            if outputs.shape[1] > 1:
                self.multi_output = True
                self.num_outputs = outputs.shape[1]
            self.expected_value = outputs.mean(0).cpu().numpy()