def _parse_adj(self, connectivity: Union[(SparseTensArray, Tuple[DataArray])], target_layout: Optional[str]=None) -> Tuple[(Optional[Adj], Optional[Tensor])]:
    if (connectivity is None):
        return (None, None)
    if isinstance(connectivity, DataArray.__args__):
        connectivity = utils.copy_to_tensor(connectivity)
    elif isinstance(connectivity, (list, tuple)):
        connectivity = recursive_apply(connectivity, utils.copy_to_tensor)
    elif isinstance(connectivity, ScipySparseMatrix):
        connectivity = SparseTensor.from_scipy(connectivity)
    elif (not isinstance(connectivity, SparseTensor)):
        raise TypeError('`connectivity` must be a dense matrix or in COO format (i.e., an `edge_index`).')
    if (target_layout is not None):
        connectivity = convert_torch_connectivity(connectivity, target_layout, num_nodes=self.n_nodes)
    if isinstance(connectivity, (list, tuple)):
        (edge_index, edge_weight) = connectivity
        if (edge_weight is not None):
            edge_weight = utils.cast_tensor(edge_weight, self.precision)
    else:
        (edge_index, edge_weight) = (connectivity, None)
        self._check_same_dim(edge_index.size(0), 'n_nodes', 'connectivity')
    return (edge_index, edge_weight)
def _parse_adj(self, connectivity: Union[(SparseTensArray, Tuple[DataArray])], target_layout: Optional[str]=None) -> Tuple[(Optional[Adj], Optional[Tensor])]:
    if (connectivity is None):
        return (None, None)
    if isinstance(connectivity, DataArray.__args__):
        connectivity = utils.copy_to_tensor(connectivity)
    elif isinstance(connectivity, (list, tuple)):
        connectivity = recursive_apply(connectivity, utils.copy_to_tensor)
    elif isinstance(connectivity, ScipySparseMatrix):
        connectivity = SparseTensor.from_scipy(connectivity)
    elif (not isinstance(connectivity, SparseTensor)):
        raise TypeError('`connectivity` must be a dense matrix or in COO format (i.e., an `edge_index`).')
    if (target_layout is not None):
        connectivity = convert_torch_connectivity(connectivity, target_layout, num_nodes=self.n_nodes)
    if isinstance(connectivity, (list, tuple)):
        (edge_index, edge_weight) = connectivity
        if (edge_weight is not None):
            edge_weight = utils.cast_tensor(edge_weight, self.precision)
    else:
        (edge_index, edge_weight) = (connectivity, None)
        self._check_same_dim(edge_index.size(0), 'n_nodes', 'connectivity')
    return (edge_index, edge_weight)