code: def from_pb(cls, app_profile_pb, instance):
          
          match_app_profile_name = _APP_PROFILE_NAME_RE.match(app_profile_pb.name)
          if match_app_profile_name is None:
              raise ValueError(
                  "AppProfile protobuf name was not in the " "expected format.",
                  app_profile_pb.name,
              )
          if match_app_profile_name.group("instance") != instance.instance_id:
              raise ValueError(
                  "Instance ID on app_profile does not match the "
                  "instance ID on the client"
              )
          if match_app_profile_name.group("project") != instance._client.project:
              raise ValueError(
                  "Project ID on app_profile does not match the "
                  "project ID on the client"
              )
          app_profile_id = match_app_profile_name.group("app_profile_id")
  
          result = cls(app_profile_id, instance)
          result._update_from_pb(app_profile_pb)
          return result
docs: Creates an instance app_profile from a protobuf.
  
          :type app_profile_pb: :class:`instance_pb2.app_profile_pb`
          :param app_profile_pb: An instance protobuf object.
  
          :type instance: :class:`google.cloud.bigtable.instance.Instance`
          :param instance: The instance that owns the cluster.
  
          :rtype: :class:`AppProfile`
          :returns: The AppProfile parsed from the protobuf response.
  
          :raises: :class:`ValueError <exceptions.ValueError>` if the AppProfile
                   name does not match
                   ``projects/{project}/instances/{instance_id}/appProfiles/{app_profile_id}``
                   or if the parsed instance ID does not match the istance ID
                   on the client.
                   or if the parsed project ID does not match the project ID
                   on the client.