code: def _check_ri(ri, cls, exact_str=True, localpath=None, **fields):
      """just a helper to carry out few checks on urls"""
      with swallow_logs(new_level=logging.DEBUG) as cml:
          ri_ = cls(**fields)
          murl = RI(ri)
          assert murl.__class__ == cls  # not just a subclass
          assert murl == ri_
          if isinstance(ri, str):
              assert str(RI(ri)) == ri
          assert (
              eval(repr(ri_)) == ri
          )  # repr leads back to identical ri_
          assert (
              ri == ri_
          )  # just in case ;)  above should fail first if smth is wrong
          if not exact_str:
              assert_in("Parsed version of", cml.out)
      if exact_str:
          assert str(ri) == str(ri_)
      else:
          assert str(ri) != str(ri_)
  
      # and that we have access to all those fields
      nok_(set(fields).difference(set(cls._FIELDS)))
      for f, v in fields.items():
          assert getattr(ri_, f) == v
  
      if localpath:
          if cls == URL:
              local_representation = local_url_path_representation(
                  localpath
              )
          else:
              local_representation = local_path_representation(
                  localpath
              )
          assert ri_.localpath == local_representation
          old_localpath = ri_.localpath  # for a test below
      else:
          # if not given -- must be a remote url, should raise exception on
          # non-Windows systems. But not on Windows systems because we allow UNCs
          # to be encoded in URLs
          if not on_windows:
              with assert_raises(ValueError):
                  ri_.localpath
  
      # This one does not have a path. TODO: either proxy path from its .RI or adjust
      # hierarchy of classes to make it more explicit
      if cls == GitTransportRI:
          return
      # do changes in the path persist?
      old_str = str(ri_)
      ri_.path = newpath = opj(ri_.path, "sub")
      assert ri_.path == newpath
      assert str(ri_) != old_str
      if localpath:
          assert ri_.localpath == local_path_representation(
              opj(old_localpath, "sub")
          )
  
imports: import logging
  import os
  import tempfile
  from os.path import isabs
  from os.path import join
  import pytest
  import datalad.support.network
  from datalad.distribution.dataset import Dataset
  from datalad.support.network import RI, SSHRI, URL, DataLadRI, GitTransportRI, PathRI, _split_colon, dlurljoin, get_local_file_url, get_response_disposition_filename, get_tld, get_url_straight_filename, is_datalad_compat_ri, is_ssh, is_url, iso8601_to_epoch, local_path_representation, local_path2url_path, local_url_path_representation, parse_url_opts, quote_path, same_website, urlquote, url_path2local_path
  from datalad.tests.utils_pytest import OBSCURE_FILENAME, SkipTest, assert_in, assert_raises, assert_status, eq_, get_most_obscure_supported_name, known_failure_githubci_win, neq_, nok_, ok_, skip_if, swallow_logs, with_tempfile
  from datalad.utils import Path, PurePosixPath, on_windows
  from ..network import rfc2822_to_epoch
label_desc: Use image node_id 10 for calling a global function with example usage: _check_ri(ri, cls, exact_str, localpath) without return types