code: def _to_slug(name):
      if not isinstance(name, str):
          raise ValueError(
              "Expected string; found %s: %s" % (type(name), name)
          )
  
      if len(name) > _NAME_LENGTH_RANGE[1]:
          raise ValueError(
              "'%s' is too long; length %d > %d"
              % (name, len(name), _NAME_LENGTH_RANGE[1])
          )
  
      safe = []
      last = ""
      for c in name:
          s = _sanitize_char(c)
          if s and (s != "-" or last != "-"):
              safe.append(s)
              last = s
  
      slug = "".join(safe).strip("-").lower()
  
      if len(slug) < _NAME_LENGTH_RANGE[0]:
          raise ValueError(
              "'%s' has invalid slug-friendly name '%s'; length %d < %d"
              % (name, slug, len(slug), _NAME_LENGTH_RANGE[0])
          )
  
      if len(slug) > _NAME_LENGTH_RANGE[1]:
          raise ValueError(
              "'%s' has invalid slug-friendly name '%s'; length %d > %d"
              % (name, slug, len(slug), _NAME_LENGTH_RANGE[1])
          )
  
      return slug
  
file_path: fiftyone/fiftyone/migrations/revisions/v0_19_0.py
imports: from datetime import datetime
  import logging
  import string
  from bson import ObjectId
label_desc: Use image node_id 9 for calling a global function with example usage: _to_slug(name) and returns: slug