Project: 067_Cut_Your_Losses_in_Large-Vocabulary_Language_Model | Function: linear_cross_entropy (iclr)

system: You are an expert Python programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow Python best practices and maintain consistent code style.
Return **only** the complete Python function code.

user: Complete this Python function:

**DESCRIPTION:** Main Cut Cross-Entropy interface implementing memory-efficient cross-entropy loss computation without materializing the full logit matrix, using custom kernels and gradient filtering

**KEY TERMS:** {
  "e": "network embeddings E",
  "c": "linear classifier C",
  "targets": "ground-truth next token labels",
  "impl": "implementation type (CCE or torch_compile)",
  "filter_eps": "gradient filtering threshold"
}

**CONTEXT CODE:** import torch
import torch.nn as nn

from cut_cross_entropy.cce_utils import CCEPreset, CCEPresets, LinearCrossEntropyImpl
from cut_cross_entropy.constants import IGNORE_INDEX
from cut_cross_entropy.doc import (
    CCE_OPTS_DOC,
    DTENSOR_NOTE,
    IMPL_DOC,
    LINEAR_CROSS_ENTROPY_DOC,
    add_doc_end,
    add_doc_start,
)
from cut_cross_entropy.torch_compile import torch_compile_linear_cross_entropy
from cut_cross_entropy.utils import (
    CCEWarning,
    is_torch_greater_or_equal_2_5,
    is_triton_3_2,
    maybe_type_as,
    to_full_tensor,
)
# from cut_cross_entropy.vocab_parallel import VocabParallelOptions
# Mock VocabParallelOptions
class VocabParallelOptions:
    def __init__(self, **kwargs):
        for k, v in kwargs.items():
            setattr(self, k, v)

warnings.filterwarnings("once", category=CCEWarning, module="cut_cross_entropy")

PLATFORM_SYSTEM = platform.system()

if TYPE_CHECKING or PLATFORM_SYSTEM != "Darwin":
    from cut_cross_entropy.cce_golden import cce_linear_cross_entropy

    LCE_IMPL_DEFAULT = LinearCrossEntropyImpl.CCE
else:
    cce_linear_cross_entropy = None
    LCE_IMPL_DEFAULT = LinearCrossEntropyImpl.TORCH_COMPILE

if TYPE_CHECKING or is_torch_greater_or_equal_2_5():
    import torch.distributed.tensor


is_d_tensor_error_message = (
    "Received {name} as a torch.distributed.tensor.DTensor. This is not supported. "
)


@overload
def linear_cross_entropy(
    e: torch.Tensor,
    c: torch.Tensor,
    targets: torch.Tensor,
    bias: torch.Tensor | None = None,
    ignore_index: int = IGNORE_INDEX,
    softcap: float | None = None,
    reduction: str = "mean",
    shift: bool | int = 0,
    return_lse: Literal[False] = False,
    filter_eps: float | str | None = "auto",
    accum_e_fp32: bool = False,
    accum_c_fp32: bool = False,
    filter_e_grad: bool = True,
    filter_c_grad: bool = True,
    impl: str | LinearCrossEntropyImpl = LCE_IMPL_DEFAULT,
    vocab_parallel_options: VocabParallelOptions | None = None,
) -> torch.Tensor: ...


@overload
def linear_cross_entropy(
    e: torch.Tensor,
    c: torch.Tensor,
    targets: torch.Tensor,
    bias: torch.Tensor | None = None,
    ignore_index: int = IGNORE_INDEX,
    softcap: float | None = None,
    reduction: str = "mean",
    shift: bool | int = 0,
    return_lse: Literal[True] = True,
    filter_eps: float | str | None = "auto",
    accum_e_fp32: bool = False,
    accum_c_fp32: bool = False,
    filter_e_grad: bool = True,
    filter_c_grad: bool = True,
    impl: str | LinearCrossEntropyImpl = LCE_IMPL_DEFAULT,
    vocab_parallel_options: VocabParallelOptions | None = None,
) -> tuple[torch.Tensor, torch.Tensor]: ...


@overload
def linear_cross_entropy(
    e: torch.Tensor,
    c: torch.Tensor,
    targets: torch.Tensor,
    bias: torch.Tensor | None = None,
    ignore_index: int = IGNORE_INDEX,
    softcap: float | None = None,
    reduction: str = "mean",
    shift: bool | int = 0,
    return_lse: bool = False,
    filter_eps: float | str | None = "auto",
    accum_e_fp32: bool = False,
    accum_c_fp32: bool = False,
    filter_e_grad: bool = True,
    filter_c_grad: bool = True,
    impl: str | LinearCrossEntropyImpl = LCE_IMPL_DEFAULT,
    vocab_parallel_options: VocabParallelOptions | None = None,
) -> torch.Tensor | tuple[torch.Tensor, torch.Tensor]: ...


@add_doc_start(LINEAR_CROSS_ENTROPY_DOC)
@add_doc_start(*(doc_str + " Only valid for the cce implementation." for doc_str in CCE_OPTS_DOC))
@add_doc_start(IMPL_DOC)
@add_doc_end(DTENSOR_NOTE)
def linear_cross_entropy(
    e: torch.Tensor,
    c: torch.Tensor,
    targets: torch.Tensor,
    bias: torch.Tensor | None = None,
    ignore_index: int = IGNORE_INDEX,
    softcap: float | None = None,
    reduction: str = "mean",
    shift: bool | int = 0,
    return_lse: bool = False,
    filter_eps: float | str | None = "auto",
    accum_e_fp32: bool = False,
    accum_c_fp32: bool = False,
    filter_e_grad: bool = True,
    filter_c_grad: bool = True,
    impl: str | LinearCrossEntropyImpl = LCE_IMPL_DEFAULT,
    vocab_parallel_options: VocabParallelOptions | None = None,
) -> torch.Tensor | tuple[torch.Tensor, torch.Tensor]:
    """
    :param vocab_parallel_options: Used to enable vocab parallelism."""

    raise NotImplementedError("Function implementation has been masked for testing")
    


class LinearCrossEntropy(nn.Module):
    def __init__(
        self,
        ignore_index: int = IGNORE_INDEX,
        softcap: float | None = None,
        reduction: str = "mean",
        shift: bool | int = 0,
        filter_eps: float | str | None = "auto",
        accum_e_fp32: bool = False,


Complete the function implementation replacing "raise NotImplementedError".