<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prefix_with_ns_if_necessary(name, name_ns, source_ns):
 # type: (typing.Text, ApiNamespace, ApiNamespace) -> typing.Text """ Returns a name that can be used to reference `name` in namespace `name_ns` from `source_ns`. If `source_ns` and `name_ns` are the same, that's just `name`. Otherwise it's `name_ns`.`name`. """

    if source_ns == name_ns:
        return name
    return '{}.{}'.format(fmt_namespace(name_ns.name), name)