<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def applicationinsights_mgmt_plane_client(cli_ctx, _, subscription=None):
 """Initialize Log Analytics mgmt client for use with CLI."""

    from .vendored_sdks.mgmt_applicationinsights import ApplicationInsightsManagementClient
    from azure.cli.core._profile import Profile
    profile = Profile(cli_ctx=cli_ctx)
    # Use subscription from resource_id where possible, otherwise use login.
    if subscription:
        cred, _, _ = profile.get_login_credentials(subscription_id=subscription)
        return ApplicationInsightsManagementClient(
            cred,
            subscription
        )
    cred, sub_id, _ = profile.get_login_credentials()
    return ApplicationInsightsManagementClient(
        cred,
        sub_id
    )