code: def names(
      source=None,
      path=None,
      encoding="utf-8",
      all_scopes=False,
      definitions=True,
      references=False,
      environment=None,
  ):
      """
      Returns a list of `Definition` objects, containing name parts.
      This means you can call ``Definition.goto_assignments()`` and get the
      reference of a name.
      The parameters are the same as in :py:class:`Script`, except or the
      following ones:
  
      :param all_scopes: If True lists the names of all scopes instead of only
          the module namespace.
      :param definitions: If True lists the names that have been defined by a
          class, function or a statement (``a = b`` returns ``a``).
      :param references: If True lists all the names that are not listed by
          ``definitions=True``. E.g. ``a = b`` returns ``b``.
      """
  
      def def_ref_filter(_def):
          is_def = _def._name.tree_name.is_definition()
          return definitions and is_def or references and not is_def
  
      def create_name(name):
          if name.parent.type == "param":
              cls = ParamName
          else:
              cls = TreeNameDefinition
          is_module = name.parent.type == "file_input"
          return cls(
              module_context.create_context(
                  name if is_module else name.parent
              ),
              name,
          )
  
      # Set line/column to a random position, because they don't matter.
      script = Script(
          source,
          line=1,
          column=0,
          path=path,
          encoding=encoding,
          environment=environment,
      )
      module_context = script._get_module()
      defs = [
          classes.Definition(script._evaluator, create_name(name))
          for name in get_module_names(script._module_node, all_scopes)
      ]
      return sorted(
          filter(def_ref_filter, defs), key=lambda x: (x.line, x.column)
      )
  
imports: import os
  import sys
  import warnings
  import parso
  from parso.python import tree
  from jedi._compatibility import force_unicode, is_py3
  from jedi.parser_utils import get_executable_nodes
  from jedi import debug
  from jedi import settings
  from jedi import cache
  from jedi.api import classes
  from jedi.api import interpreter
  from jedi.api import helpers
  from jedi.api.completion import Completion
  from jedi.api.environment import InterpreterEnvironment
  from jedi.api.project import get_default_project
  from jedi.evaluate import Evaluator
  from jedi.evaluate import imports
  from jedi.evaluate import usages
  from jedi.evaluate.arguments import try_iter_content
  from jedi.evaluate.helpers import get_module_names, evaluate_call_of_leaf
  from jedi.evaluate.sys_path import dotted_path_in_sys_path
  from jedi.evaluate.filters import TreeNameDefinition, ParamName
  from jedi.evaluate.syntax_tree import tree_name_to_contexts
  from jedi.evaluate.context import ModuleContext
  from jedi.evaluate.context.iterable import unpack_tuple_to_dict
label_desc: Use image node_id 1 for calling a global function with example usage: names(source, path, encoding, all_scopes, definitions, references, environment) and returns: sorted, unknown, cls