parameters: (name, import_scope)
docstring: Prepends name scope to a name.
  
    Args:
      name: A `string` name.
      import_scope: Optional `string`. Name scope to add.
  
    Returns:
      Name with name scope added, or the original name if import_scope
      is None.
docstring_summary: Prepends name scope to a name.
docstring_tokens: Prepends name scope to a name .
function: def prepend_name_scope(name, import_scope):
    """Prepends name scope to a name.
  
    Args:
      name: A `string` name.
      import_scope: Optional `string`. Name scope to add.
  
    Returns:
      Name with name scope added, or the original name if import_scope
      is None.
    """
    if import_scope:
      try:
        str_to_replace = r"([\^]|loc:@|^)(.*)"
        return re.sub(str_to_replace, r"\1" + import_scope + r"/\2",
                      compat.as_str(name))
      except TypeError as e:
        # If the name is not of a type we can process, simply return it.
        logging.warning(e)
        return name
    else:
      return name
function_tokens: def prepend_name_scope ( name , import_scope ) : if import_scope : try : str_to_replace = r"([\^]|loc:@|^)(.*)" return re . sub ( str_to_replace , r"\1" + import_scope + r"/\2" , compat . as_str ( name ) ) except TypeError as e : # If the name is not of a type we can process, simply return it. logging . warning ( e ) return name else : return name