code: def from_client(client: SyftClient) -> Self:
      if not client.metadata:
          raise Exception("Client has to have metadata first")
  
      peer = client.metadata.to(NodeMetadataV3).to(NodePeer)
      route = connection_to_route(client.connection)
      peer.node_routes.append(route)
      return peer
  
imports: from typing import List
  from typing import Optional
  from typing import Tuple
  from typing_extensions import Self
  from ...abstract_node import NodeType
  from ...client.client import SyftClient
  from ...node.credentials import SyftSigningKey
  from ...node.credentials import SyftVerifyKey
  from ...serde.serializable import serializable
  from ...service.response import SyftError
  from ...types.syft_object import SYFT_OBJECT_VERSION_1
  from ...types.syft_object import SyftObject
  from ...types.uid import UID
  from ..context import NodeServiceContext
  from ..metadata.node_metadata import NodeMetadataV3
  from .routes import HTTPNodeRoute
  from .routes import NodeRoute
  from .routes import NodeRouteType
  from .routes import connection_to_route
  from .routes import route_to_connection
label_desc: Use image node_id 4 for calling the NodePeer obj's underlying member method code with example usage: obj.from_client(client) and returns: peer