code: def _basename(path):
      """A basename() variant which first strips the trailing slash, if present.
      Thus we always get the last component of the path, even for directories.
  
      path: Union[PathLike, str]
  
      e.g.
      >>> os.path.basename('/bar/foo')
      'foo'
      >>> os.path.basename('/bar/foo/')
      ''
      >>> _basename('/bar/foo/')
      'foo'
      """
      path = os.fspath(path)
      sep = os.path.sep + (os.path.altsep or "")
      return os.path.basename(path.rstrip(sep))
  
imports: import os
  import sys
  import stat
  import fnmatch
  import collections
  import errno
label_desc: Use image node_id 19 for calling a global function with example usage: _basename(path) and returns: os